When working with Angular 5 HttpClient, setting HttpParams() can be a bit tricky.
const body = new HttpParams()
.set('email', 'example@example.com')
.set('password', 'pass');
However, trying to set HttpParams() in another way doesn't seem to work as expected.
const paramsMap = new Map<any, any>();
paramsMap.set("email", "example@example.com");
paramsMap.set("password", "pass");
paramsMap.forEach((value: any, key: any) => {
body.set(key, value);
});
Why is it not setting the values correctly? And what is the alternative approach to achieve the same result?