I am working on a payment system. I simulate the node.js using cloud functions. I send a request from Angular to Cloud Functions. Then, I send the second request from cloud functions to payment API. Payment API gets the request successfully and payment is successful. But, I guess because of an async structure, the response is shown as null on the Angular side.
Angular Code:
constructor(private fns: AngularFireFunctions) { } ... ... const callable = this.fns.httpsCallable('app'); var data = callable({req: request}) data.subscribe(async res => { console.log(res); }); Cloud functions:
exports.app = functions.https.onCall((data, context) => { var res = ""; iyzipay.payment.create(data.req, function (err, result) { res = result; }); return res; }); How can I wait for the response? I tried async/await but I don't know these subjects entirely. Thank you!