gpt4 book ai didi

javascript - aurelia aurelia-http-客户端 jsonp

转载 作者:行者123 更新时间:2023-11-30 11:44:52 25 4
gpt4 key购买 nike

我尝试查询与 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的截图

code source browser result

在同一台机器上使用 JQuery 没有问题。

最佳答案

看完这篇文章后other jsonp case我尝试添加工作“回调”,现在可以了!!!

所以调用 jsonp(url, 'callback')

client.jsonp(url, 'callback')

谢谢...

关于javascript - aurelia aurelia-http-客户端 jsonp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41334888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com