[英]HTTP ok STATUS axios on javascript
我正在尝试制作一个中间 api (B) 来连接两个应用程序(A,C),问题是我是 axios 的新手,我没有实现它。
从应用程序 AI 进行此调用,然后调用执行发布的服务。
const updateLead = () => {
pipelineServices.updateLeads(data.token, data.leads).then(resp => console.log(resp));
}
updateLeads(leads, token) {
let config = {
method: 'POST',
url: `http://localhost:3525/api/updateLead`,
data: {leads, token},
};
let aux = axios(config)
.then(function (response) {
if (response.status == 200) {
console.log("OK");
}
if (response.status == 401) {
console.log("User is not authorized");
}
if (response.status == 400) {
console.log("Invalid data given. Details are available in the request response");
}
})
.catch(async function (error) {
console.log("Error");
console.log(error)
});
return aux;
}
问题是LOG中的浏览器以以下方式响应我
尝试使用“cors-anywhere”来代理您的连接。 CORS Anywhere 是一个 NodeJS 反向代理,它将 CORS 标头添加到代理请求中。
您需要在localhost:3525
的应用程序中启用 CORS 。 你可以在这里阅读: https://enable-cors.org/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.