When I call my Azure Function from React, it returns a 500 Internal server error. Tried the same thing from Postman and it works fine.
My call from React:
componentDidMount() {
const obj = { name: 'test.jpg' };
sendRestRequest('GET', `${URL_API_AI_1}`, obj)
}
sendRestRequest method:
import request from 'superagent';
export const sendRestRequest = (requestAction, url, body = '') => new Promise((resolve, reject) => {
request(requestAction, url)
.send(body)
.end((error, res) => {
if (error) {
reject(error);
} else {
resolve(res.body);
}
});
});
Browser error:
GET https://"url" 500 (Internal Server Error)
client.js:440 Uncaught (in promise) Error: Internal Server Error
at Request.<anonymous> (client.js:440)
at Request.push../node_modules/component-emitter/index.js.Emitter.emit (index.js:140)
at XMLHttpRequest.xhr.onreadystatechange (client.js:732)