我尝试查询与 aurelia-http-client 不同源的 api。
我的代码非常简单:
import {HttpClient} from 'aurelia-http-client';
export class App {
constructor(){
console.log("constructor called");
let url = 'http://localhost:8081/all';
let client = new HttpClient();
client
.jsonp(url)
.then(data => {
console.log("datas");
console.log(data);
});
}
}
什么都没发生,我可以在网络中看到调用了 url,我的 api 引擎记录了一个条目,但我从未输入“ promise ”的“then”...
怎么了?
更新:
我给你一些catch的截图
在同一台机器上使用 JQuery 没有问题。
最佳答案
看完这篇文章后other jsonp case我尝试添加工作“回调”,现在可以了!!!
所以调用 jsonp(url, 'callback')
client.jsonp(url, 'callback')
谢谢...
关于javascript - aurelia aurelia-http-客户端 jsonp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41334888/