我在 axios 中调用 API 方法,例如:
let promise = axios.get('http://localhost:63711/api/AdminAPI/GetHomeCarousel');
console.log(promise);
promise.then(function(response){
console.log(response);
});
两个 console.log 都打印输出:
Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
该 api 正在GET
并且正在返回有效的 json 数据,我通过 POSTMAN 进行了检查,例如:
[
{
"type": "image",
"mediaUrls": [
"\\wwwroot\\11863226_431355017048701_7276274176291220216_n.jpg"
],
"title": "title 1",
"description": "<p>Check pic </p>\r\n<p>test yy jjasd</p>",
"url": "\\NdbSite\\wwwroot\\11863226_431355017048701_7276274176291220216_n.jpg",
"buttonText": "",
"featuredProduct": "",
"featuredProductUrl": ""
}
]
我跟着 :
http://codeheaven.io/how-to-use-axios-as-your-http-client/
我错过了什么?