VueJS 中的 Axios 正在混合 url。 localhost + URL 给出错误。应该只是 URL
Axios in VueJS is mixing the urls. localhost + URL giving error. Should be just the URL
我已经使用 Vue-cli 创建了一个项目,但 axios get 请求没有按预期工作。
axios.get("https://pokeapi.co/api/v2/pokemon")
.then(response => {
this.pokemons = response.data;
console.log(this.pokemons);
})
请求 URL 抛出 http://localhost:8080/%E2%80%8Bhttps://pokeapi.co/api/v2/%E2%80%8Bpokemon
.
它应该是 https://pokeapi.co/api/v2/%E2%80%8Bpokemon
但是本地主机把事情搞砸了。
请帮忙:(
您的字符串中有 2 个零宽度空格,一个在开头,一个在 pokemon
之前。
这可能是从文字处理器粘贴代码造成的。
一开始就是让你的 URL 被解释为亲戚 URL.
删除空格,您的 url 应该会按预期请求。
我已经使用 Vue-cli 创建了一个项目,但 axios get 请求没有按预期工作。
axios.get("https://pokeapi.co/api/v2/pokemon")
.then(response => {
this.pokemons = response.data;
console.log(this.pokemons);
})
请求 URL 抛出 http://localhost:8080/%E2%80%8Bhttps://pokeapi.co/api/v2/%E2%80%8Bpokemon
.
它应该是 https://pokeapi.co/api/v2/%E2%80%8Bpokemon
但是本地主机把事情搞砸了。
请帮忙:(
您的字符串中有 2 个零宽度空格,一个在开头,一个在 pokemon
之前。
这可能是从文字处理器粘贴代码造成的。
一开始就是让你的 URL 被解释为亲戚 URL.
删除空格,您的 url 应该会按预期请求。