Data Returned Null After Calling Function
What am trying to do : am placing a payment-order in the payment gateway's server (using firebase functions). the placeorder() creates the order (this part works) I want the detail
Solution 1:
The first thing I'd do is "promisify" the callback-style entry point for the ippopay api...
constIppopay = require('node-ippopay');
const ippopay_instance = newIppopay({
public_key: 'public key',
secret_key: 'secret key',
});
// call ippopay api to createOrder and resolve with the JSON result parsedasyncfunctionplaceorder(params) {
returnnewPromise((resolve, reject) => {
ippopay_instance.createOrder(params, (error, data) => {
if (error) reject(error);
elseresolve(JSON.parse(data));
})
});
}
Now the exported function can be made simple and clear. The key is to await the promise resolution before returning...
exports.order = functions.https.onCall((amnt, context) => {
const params = { amount: amnt, etc...}
returnawaitplaceorder(params);
})
Post a Comment for "Data Returned Null After Calling Function"