How to call POST API in excel Custom Function

Viewed 28

I want to develop a API call in excel custom function. I have developed a GET API request which is working fine in excel custom function. I have developed a POST API call in excel custom function. My POST API call working fine in chrome, and normal react app, and normal JavaScript file, but when I am running same POST API request in excel custom function it shows me "Network error", I have shared the images of code and error as well as.

Can anyone suggest what actual problem is there. Why I am not able to call POST Request from excel custom function. or What else will be solution for this. Are we not able to call the post request in excel custom function.

API Error POST Request

var details = {
    name: "env@test.com",
    job: "44444444"
  };
  let resp = await fetch('https://reqres.in/api/users', {
    method: "POST",
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(details)
  })
    .catch((err) => { return "err" });
  if (resp == "err") {
    return "err"
  }
  let resul = await resp.json();
  return resul.id
0 Answers
Related