我试图用ahttp.get
auth发出abasic
请求,其中atoken
作为用户名,然后aempty
密码
const headers_object = new HttpHeaders();
headers_object.append('Content-Type', 'application/json');
headers_object.append('Authorization', 'Basic ' + btoa(environment.CVRTOKEN + ':'));
const httpOptions = {
headers: headers_object
};
const url = 'https://rest.cvrapi.dk/v1/dk/suggestions/company/' + searchString;
return this.http.get(url, httpOptions);
但是它似乎不起作用。有人能告诉我我做错了什么吗?
当查看控制台时,我得到以下错误:
VM3464:1 GET https://rest.cvrapi.dk/v1/dk/suggestions/company/3 401 (Unauthorized)
请求头如下所示:
最佳答案