【发布时间】:2019-10-21 01:32:57
【问题描述】:
我正在使用 Ionic 本机 http 来发出服务器请求。服务器托管在 aws 上,并且 API 已启动并正在运行(由邮递员验证)。
当我执行 ionic 服务时,请求会通过并工作,但是当我尝试在设备上运行它时它不起作用。经检查,我得到“net::ERR_CLEARTEXT_NOT_PERMITTED”,帖子作为选项发送
ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: "http://18.220.143.133/api/login", ok: false, ...}
已经尝试添加到 config.xml
login(user: User): Observable<AuthResponse> {
return this.httpClient.post('http://18.220.143.133/api/login', user, {
headers: new HttpHeaders().set('Content-Type', 'application/json'),
}).pipe(
tap(async (res: AuthResponse) => {
if (res.success == true) {
await this.storage.set('user',res.user);
await this.storage.set('ACCESS_TOKEN', res.token);
this.authSubject.next(true);
}
})
);
}
我希望移动设备也能通过 http 请求。
【问题讨论】:
标签: rest http ionic-framework ionic4