Home > OS >  Post request to the firebase cloud functions gives error 500
Post request to the firebase cloud functions gives error 500

Time:03-07

I have a POST request to the Cloud Functions on Firebase. When I'm trying to make a request, I get a CORS policy error. Ok, I set mode: 'no-cors' and get Failed to load resource: the server responded with a status of 500 ().

Here is the code

 let myHeaders = new Headers();
 myHeaders.append("Content-Type", "application/json");
 myHeaders.append("Accept", "application/json");

 let raw = JSON.stringify({
    "description": "Test item",
    "email": "[email protected]"
 });

 let requestOptions = {
    method: 'POST',
    headers: myHeaders,
    body: raw,
    mode: 'no-cors',
    redirect: 'follow',
 };

 fetch("https://someURl.cloudfunctions.net/someRequest", requestOptions)
 .then(response => response.text())
 .then(result => console.log(result))
 .catch(error => console.log('error', error));

The code is copied from Postman

Any ideas?

CodePudding user response:

As confirmed by jaba, the issue was on server side. Also, same has been documented here.

  • Related