当我从React调用我的Azure函数时,它返回500内部服务器错误。从Postman尝试了同样的方法,效果很好。
我从React打来的电话
componentDidMount() {
const obj = { name: 'test.jpg' };
sendRestRequest('GET', `${URL_API_AI_1}`, obj)
}
sendRestRequest方法:
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);
}
});
});
浏览器错误:
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)