Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Node.js中从Post请求中获取回执数据_Javascript_Node.js_Server_In App Purchase - Fatal编程技术网

Javascript 如何在Node.js中从Post请求中获取回执数据

Javascript 如何在Node.js中从Post请求中获取回执数据,javascript,node.js,server,in-app-purchase,Javascript,Node.js,Server,In App Purchase,我正在尝试向我的Node.js服务器发送收据。目前,它在firebase中打印出接收数据,这表明它是从我的iOS应用程序发出的POST请求中获得的。但是,我无法在const receive=request.body中正确传递要验证的代码。我怎样才能以正确的方式传递它?。谢谢 exports.receiptValidation = functions.https.onRequest((request, response) => { const receipt = request.b

我正在尝试向我的
Node.js服务器发送
收据
。目前,它在firebase中打印出
接收数据
,这表明它是从我的
iOS应用程序发出的
POST
请求中获得的。但是,我无法在
const receive=request.body中正确传递要验证的代码。我怎样才能以正确的方式传递它?。谢谢

exports.receiptValidation = functions.https.onRequest((request, response) => {

    const receipt = request.body;
    console.log(receipt);

    iap.config({
        applePassword: 'MySharedAppleKey',
        test: true
    });

    iap.setup((error) => {
        if (error) {
            console.log('Failed to validate receipt', error);
        }
       });

    iap.validate(receipt).then((pResponse) => {
            //Check if receipt is valid
            if (iap.isValidated(pResponse)) {
                console.log('The receipt is valid', pResponse);
                response.send(pResponse);
            }
            return pResponse;
        })
        .catch((error) => {
            console.log(`Sorry couldn't validate receipt`, error);
            response.send(error);
            return error
        });
});
这是我在Firebase中的输出。我使用的是
firebase函数


我通过在
Swift
Server code

迅捷的

let receiptData = receipt!.base64EncodedString()
let requestReceiptDict = ["receipt": receiptData]
Node.js

const receipt = request.body.receipt;
console.log(receipt);