【发布时间】:2019-03-05 22:10:26
【问题描述】:
我有一个应用程序,我在其中发出类似于您在以下代码中看到的请求:
import { Injectable } from '@angular/core';
import { Http, Headers } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class ResourcesApiProvider {
public direccion = my_url_app;
constructor(public http: Http) {
}
getCars(car_id) {
let repos = this.http.get(this.direccion + 'api/cars.json' + '?car_id=');
return repos;
}
}
我现在通过 HTTP 和 HTTPS 都响应的 API,但我想将所有通信更改为 HTTPS,所以我想知道......我可以做什么,以便 Angular / Ionic 应用程序将加密请求发送到API?,当我做作业public direccion = my_url_app时,只使用我的API的HTTPS URL就足够了吗?
我问是因为some answers from here 说我必须在最后添加/,但我不确定是否仍然如此,等等。
您好。
【问题讨论】:
-
你需要使用 rxjs 并从那里调用 apis
-
您能详细说明一下吗?以一些代码为例来回答?等
-
@OiciTrap 是您的客户端应用程序也托管在
https上吗? -
您提供的链接适用于 Angular 1.x。如果它们在同一个端口上,只需将 API url 中的 http 替换为 https 就足够了
-
@PankajParkar 客户端只是一个移动应用程序
标签: angular ionic-framework angular-http