我想在react项目中使用axios从我的服务器调用产品。我正在使用redux.When,我已经在组件中触发了使用效果的动作,我的产品还没有来,但是,我的产品来了没有使用使用效果。
在我的组件中:
async function get(){
await props.getProducts()
console.log(props.products)
}
useEffect(() => {
get()
}, []); when I write 'get or get()' in square brackets , pro
我正在尝试将我的部署到运行Ubuntu的远程服务器上。我的应用程序在我的pc上运行得很好。现在,在线部署后,当前端尝试使用axios调用后端的api时,它会显示此错误,错误是: GET http://localhost:8000/posts net::ERR_CONNECTION_REFUSED
createError.js:16 Uncaught (in promise) Error: Network Error
at e.exports (createError.js:16)
at XMLHttpRequest.d.onerror (xhr.js:87) 我不明白这个问题
昨晚我在摆弄ExpressJS,发现给出了一个简单的代码:
app.post('/contact', function(req, res, next) {
res.send('Congrats you have submitted the form');
});
我能够从服务器端正确地响应它,并且实际上发送了一个空白文档,上面写着“恭喜您提交了表单”。
但是,当我删除"action“属性并尝试使用javascript处理它以执行POST请求时,例如使用axios模块,它就无法工作:
axios.post('/contact', { d
当向服务器发送请求时,我遇到了这个问题:
Access to XMLHttpRequest at 'http://localhost:5000/api/distance' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials'