我使用kong作为我的API的基本身份验证。当使用Postman时,它工作得很好。但每当我想使用axios将其集成到我的应用程序中时,它都会抛出错误。请帮帮我。谢谢!
下面是我的代码:
我的main.js文件:
var app5 = new Vue({
el: '#app-5',
data: {
message: ''
},
methods: {
getQuote() {
var config = { url: '/allquotes',
baseURL: 'http://localhost:8000/',
headers: {'Host': 'quotesapi.com/'},
withCredentials: false,
auth: {
username: 'Aladdin',
password: 'OpenSesame'
},
responseType: 'json'
}
axios.get(config)
.then(
response => {
this.message = (response.data.quotes[0].quotes);
})
.catch(function (error){
console.log('Error on Authentication');
});
}
}
})控制台错误消息:console error message
发布于 2018-02-09 00:48:27
您的localhost/part2/ /!\ This one /!\参数是一个原始对象。
我认为你必须这样做:在调用后端之前使用JSON.Stringify(youObject),或者像axios.post(url, data)一样通过POST方法发送
https://stackoverflow.com/questions/48690573
复制相似问题