I am calling an Azure Function which is publicly accessible from my SPFx web part.
It is a POST Request and I am getting a Failed to Fetch error.
The same API call is working fine if I execute it from POSTMAN.
Below is the code.
fetch(checkSubscriptionURL, {
method: "POST",
body: JSON.stringify({ "TenantID": tenantId }),
headers: {
"Content-type": "application/json",
"Accept": "application/json"
}
}).then((res) => {
console.log(res);
if (res.status !== 200) {
reject();
}
else {
res.json().then(data => {
if (data && data.length > 0) {
resolve(this.parseSubscription(data[0]));
}
else {
reject();
}
})
}
}).catch((e) => {
console.log(e);
reject();
})
Can anyone please help with this?
I tried to make the call with SPFxHTTPClient but getting the same error with that as well.
Thanks in advance.

