【发布时间】:2021-05-19 07:03:48
【问题描述】:
我正在尝试使用 axios 在我的 nuxt 应用程序中向 githubjobs API 发出获取请求。我已经正确设置和配置了 axios。这是我要调度的操作:
async defaultJobsFetch({commit}){
try{
const res = await axios.get('https://jobs.github.com/positions.json?location=new+york')
const jobs = res.data;
commit('getJobs', jobs)
}catch(error){
commit("errored");
console.log(error)
}
finally{
commit('changeLoading')
}
},
我也尝试使用https://cors-anywhere.herokupp.com/,但仍然收到错误 403 禁止
我注意到它在我的本地机器上运行良好,但是当我部署并尝试加载已部署的应用程序时,我没有得到响应,而是收到 403 错误。该应用托管在heroku,http://hubjobs.herokuapp.com,访问该站点时检查控制台以查看错误
【问题讨论】:
标签: javascript api axios nuxt.js