-3

I'm trying to add the body to the HTTP GET request. But not able to add

I have tried with RequestOptions but it did not work.

For the mentioned code, POST Request is working but GET is not working

getlist(name : string) : Observable<Object[]> {

var body = {
  "listname" : name
}

 return this.http.post<any>("http:/regsd.com/api/lists/",body)
}

Shivaay
  • 189
  • 1
  • 3
  • 14

1 Answers1

1

You can pass query params in GET request.

getlist(name : string) : Observable<Object[]> {
  return this.http.get<any>(`http:/regsd.com/api/lists/?listname=${name}`);
}

Body can be only set in POST and other verb like PUT in HTTP.

Anshuman Jaiswal
  • 5,139
  • 1
  • 28
  • 46