提问人:user6781 提问时间:11/18/2023 更新时间:11/18/2023 访问量:10
在 ionic 6 中为 http 请求设置超时
Setting a timeout for a http request in ionic 6
问:
我需要为我的 http 请求设置超时。我在网上找到的内容如下:
public async GETRequest(url: string, parameters: any, headers: any): Promise<any> {
return new Promise((resolve, reject) => {
setTimeout(() => {
this.http.get(url, parameters, headers)
.then(
(res:any) => {
console.error('res is: ', res);
resolve(res);
},
(error:any) => {
console.error('error is: ', error);
reject(error);
}
);}
, 1000);
});
}
但是,它没有按预期工作!有谁知道出了什么问题?谢谢!
答: 暂无答案
评论
this.http.get()