var payUrl;
var orderId;
async function getInvoice() {
var data = JSON.stringify({
"price_amount": 10,
"price_currency": "gbp",
});
var config = {
method: 'post',
url: 'https://api.nowpayments.io/v1/invoice',
headers: {
'x-api-key': 'api-key',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
orderId = response.data.id;
payUrl = response.data.invoice_url;
});
}
getInvoice();
console.log(payUrl);
This code returns undefined. I need the code to set the global variable to the response data needed so i can access it in other functions.