I have thins very simple function:
createParams(paramsArray, withToken: boolean): HttpParams {
let params = new HttpParams();
let currentUser = JSON.parse(localStorage.getItem('currentUser'));
params.set('access_token', JSON.stringify(currentUser.token));
return params;
}
When i debug this the params variable does not contain any keys nor values:
What am i doing wrong?
Try this:
let Params = new HttpParams();
Params = Params.append('access_token', JSON.stringify(currentUser.token));
OR
let params = new HttpParams().set('access_token', JSON.stringify(currentUser.token));
HttpParams
is intended to be immutable. Theset
andappend
methods don't modify the existing instance. Instead they return new instances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With