I'm trying to make a get/post request to an Express+Node server using URLSearchParams from an Angular 4 app and no matter what I do I can´t get the data in the server.
I'm doing something like this
let params: URLSearchParams = new URLSearchParams();
params.set('company', company);
return this.authHttp
.get(`${api}/${id}`, { search: params, params })
The second parameter for http.get is RequestOptionsArgs, which is
interface RequestOptionsArgs {
url?: string|null
method?: string|RequestMethod|null
search?: string|URLSearchParams|{[key: string]: any | any[]}|null
params?: string|URLSearchParams|{[key: string]: any | any[]}|null
headers?: Headers|null
body?: any
withCredentials?: boolean|null
responseType?: ResponseContentType|null
}
so this should be working fine, but when I try to get req.query.company in the server it turns out that req.query is undefined. In req.params I can find the id that I send in the url, but no company either.
Any idea about what I might be doing wrong?
Thanks