【发布时间】:2018-12-03 21:50:37
【问题描述】:
我正在尝试向某个 URL 发出 get 请求,但它似乎被替换为另一个,这导致向不存在的 URL 发出 get 请求。
这是我的代码
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
@Injectable()
export class ApitestProvider {
tests;
apiUrl = "http//:localhost:8000/api";
testAdded;
testGotten;
testDeleted;
constructor(public http: HttpClient) {
console.log('Hello ApitestProvider Provider');
}
getTests() {
this.http.get(this.apiUrl + "/tests").subscribe(data => {
console.log(data);
this.testGotten = data;
}), err => {
console.log(err);
}
}
但它最终会请求以下 URL
url: "http://localhost:8100/http//:localhost:8000/api/tests"
提前致谢。
【问题讨论】:
-
你在使用拦截器吗?
-
您可以在
index.html文件中检查您的基本网址。
标签: angular http ionic-framework get request