-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
  • 359
  • 1
  • 6
  • 19

1 Answers1

2

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,352
  • 1
  • 29
  • 46