I'm trying to make a get request to a certain URL but it seems to be replaced to another one,this resulting in making a get request to an non-existant URL.
Here is my code
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);
}
}
but it ends up making a request for the following URL
url: "http://localhost:8100/http//:localhost:8000/api/tests"
thanks in advance.
You have incorrectly typed your API URL.
instead of this: apiUrl = 'http//:localhost:8000/api';
it should be this: apiUrl= 'http://localhost:8000/api';