0
爲什麼我無法從API獲取JSON響應?我有這個函數向我的API發出axios POST請求。Axios不輸出Console.log,但正在返回JSON數據
handleSubmit(event) {
axios.post('/api/v1/user_token/',{
auth: {
email: this.state.email,
password: this.state.password
}
})
.then(function(response) {
console.log(response.data);
console.log(response.statusText);
})
.catch(function (error) {
console.log(error);
})
}
它在Response主體中返回正確的JsonWebToken。但是,當我嘗試設置一個cookie或輸出到console.log,如console.log(response.data)
我看不出任何輸出。附有相關圖片。
有使用'postman'想你的API ... –
好像是端點工作纔剛剛返回用戶令牌,僅此而已。似乎不應該返回任何數據。 – dcodesmith
我會嘗試郵遞員,因爲我看到令牌返回。但是我不知道如何把它設置成Cookie,如果我無法捕捉到它。 – amishpanda