vue project, there is a cross-domain problem in accessing Douban"s API, using axios. Referring to the method on the Internet, the following configuration is added to the dev of config/index.js
proxyTable: {
"/api": {
target: "http://api.douban.com/v2",
changeOrigin: true,
pathRewrite: {
"^/api": ""
}
}
}
the code to send the request is as follows
export default {
name:"Douban",
created:function(){
this.$axios.get("/api/movie/in_theaters")
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
}
}
after npm run dev starts the project, the data cannot be obtained. Browser request 504 error.
Terminal information is as follows
I Your application is running here: http://localhost:8080
[HPM] Error occurred while trying to proxy request /movie/in_theaters from localhost:8080 to http://api.douban.com/v2 (ENOTFOUND) (https://nodejs.org/api/errors.html-sharperrors_common_system_errors)