Open BehnamAbdy opened 5 years ago
Looks like they changed the way request headers are passed in.
This worked for me using 1.6.3:
this.dataService = this.completerService.remote(null, 'name', 'name');
let options = new RequestOptions({
headers: new Headers({
Authorization: 'token ' + localStorage.getItem('token')
})
});
(<RemoteData>this.dataService ).requestOptions(options);
This is what it looks line now that i'm using 2.0.8:
this.dataService = this.completerService.remote(null, 'name', 'name');
(<RemoteData>this.dataService).requestOptions({
headers: {
Authorization: 'token ' + localStorage.getItem('token')
}
});
Believe the change occurred with release of v2.0.0 https://github.com/oferh/ng2-completer/blob/master/CHANGELOG.md
Another interesting note... the demo... https://oferh.github.io/ng2-completer/#/native (Remote data with URL Formater and Headers
) doesn't add remote headers as far as i can see.. https://github.com/oferh/ng2-completer/blob/master/demo/native-cmp.ts#L94-L101
hi i want the ngautocomplete to sent a custom httpheader while calling the api but it doesnt send the added header, here is the code i use:
public dataService: RemoteData;
constructor(private completerService: CompleterService) { this.dataService = completerService.remote(
some url
, 'label', 'label'); let options = new RequestOptions({ headers: new Headers() }); options.headers.set('api-key', 'some credentials'); this.dataService.requestOptions(options);}
<ng2-completer [(ngModel)]="partTerm" [ngModelOptions]="{standalone: true}" [datasource]="dataService" [clearUnselected]="true" [inputClass]="'form-control'" [placeholder]="'search by term'" [minSearchLength]="2" [pause]="500" (selected)="selected($event)"> i'll appreciate it