Angular 6: I looking to create an REST API require in GET with a basic authentication. I don't understand how should put my params (user + password).
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class DataService {
constructor(private http: HttpClient) { }
getCountry(){
const params = new HttpParams().set('username', '****').set('password', '*****');
return this.http.get('****', { params })
}
}
In this way my user + password are in the path of the request and at the console I have this error:
Access to XMLHttpRequest at '****?username=****&password=****' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.