简体   繁体   English

Axios:未捕获(承诺)TypeError:无法读取未定义的属性“协议”

[英]Axios: Uncaught (in promise) TypeError: Cannot read property 'protocol' of undefined

I am getting the title error after running the following function in React: 在React中运行以下功能后,出现标题错误:

  const postToApi = (event) => {
    event.preventDefault();
    axios.post(process.env.API_POST_URL, {step : "3"}) 
      // API_POST_URL: http://localhost:4000/api/donate
      .then(res => {
        console.log(res);
        console.log(res.data);
      })
  };

My React app is on localhost:3000. 我的React应用程序位于localhost:3000上。 Mentioning this because the file causing the error is: isURLSameOrigin.js:51 提及此问题是因为引起错误的文件是:isURLSameOrigin.js:51

Sorry, my reputation is not high enough to leave a comment and ask questions. 抱歉,我的声誉不够高,无法发表评论并提出问题。 Have you recently added the URL to your .env? 您最近是否将该URL添加到了.env? If so try stopping your npm/yarn and start it again. 如果是这样,请尝试停止您的npm / yarn,然后重新启动。 Applications compile your .env at the beginning of your dev server. 应用程序在开发服务器的开头编译.env。 If that does not work have you tried placing the URL directly into it? 如果这样不起作用,您是否尝试过将URL直接放入其中?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获(承诺中)类型错误:无法读取未定义的属性“协议” - Uncaught (in promise) TypeError: Cannot read property 'protocol' of undefined Vue.js通过Axios消耗API给出错误:未捕获(已承诺)TypeError:无法读取未定义的属性“协议” - Vue.js Consuming API through Axios giving error : Uncaught (in promise) TypeError: Cannot read property 'protocol' of undefined 未捕获(承诺)类型错误:无法读取未定义的 React/Redux/Axios 的属性“数据” - Uncaught (in promise) TypeError: Cannot read property 'data' of undefined React/Redux/Axios 我在 axios 补丁 api 中收到“Uncaught (in promise) TypeError: Cannot read property 'data' of undefined”错误 - I'm getting “Uncaught (in promise) TypeError: Cannot read property 'data' of undefined” error in axios patch api 未捕获(承诺)类型错误:无法使用 axios 设置未定义的属性 - Uncaught (in promise) TypeError: Cannot set property of undefined with axios axios TypeError:无法读取 express 中未定义的属性“协议” - axios TypeError: Cannot read property 'protocol' of undefined in express Axios 未捕获类型错误:无法读取未定义的属性“映射” - Axios Uncaught TypeError: Cannot read property 'map' of undefined 未捕获(承诺中):TypeError:无法读取未定义的属性“userSubject”类型错误:无法读取未定义的属性“userSubject” - Uncaught (in promise): TypeError: Cannot read property 'userSubject' of undefined TypeError: Cannot read property 'userSubject' of undefined 未捕获(承诺)TypeError:无法读取未定义的属性'uid' - Uncaught (in promise) TypeError: Cannot read property 'uid' of undefined 未捕获(承诺)类型错误:无法读取未定义的属性“fisierUrl” - Uncaught (in promise) TypeError: Cannot read property 'fisierUrl' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM