I am using a node npm module in a next js app to get data from an api.
static async getInitialProps() {
const zxapi = new Zxapi(connectId, secretKey);
const res2 = await zxapi.programs({ region: "DE" }, function(err, result) {
if (err != null) {
return err
}
console.log(result, "before return");
return result
console.log(result, "after return");
});
return { res2 };
}
I need to return the values of res2
. The "before return" console.log
logs the data to the terminal and terminates there. What am I doing wrong? Thanks