【发布时间】:2019-10-16 14:27:58
【问题描述】:
我在 Windows 上使用 Nativescript sidekick cloud build 在 iOS 上测试我的应用 - 我还连接了我的 iPhone。
根据this 的帖子,我正在向 localhost 发送我的 http 请求,但他们一直因为这个错误而失败。
http://localhost:52553/api/rewards/all 的 Http 失败响应:0 未知错误
错误:无法连接到服务器。
这是我的奖励服务实现
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Observable, of } from 'rxjs';
import { SimpleReward } from "../models/simple-reward";
import { take, catchError } from "rxjs/operators";
@Injectable()
export class RewardsService {
private baseUrl = "http://localhost:52553/api/rewards";
constructor(private http: HttpClient) { }
getAllRewards(): Observable<SimpleReward[]> {
const url = `${this.baseUrl}/all`;
return this.http.get<SimpleReward[]>(url).pipe(
catchError((e) => {
console.error(e);
return of([]);
})
);
}
}
请指导我在这里做错了什么?
【问题讨论】:
-
将 NSAppTransportSecurity 添加为默认情况下 ios 中不允许使用非 https
标签: angular nativescript