Angular 2 Http Service GET with body

Viewed 3956

I want to use a body in my GET request. I am not finding any way to do it with Angular 2/4.

I Found the body attribute in the RequestOptionsArgs class, but it is not sending in the http request.

With httpie.org it's possible to send it like this :

http --verbose GET 'http://localhost/api/test' 'Content-Type: application/json' 'foo=bar'

This is sending this raw request:

GET /api/test HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 14
Content-Type: application/json
Host: localhost
User-Agent: HTTPie/0.9.9
enter code here
{
    "foo": "bar"
}

this.http.get("/api/test", {body: JSON.stringify{foo: "bar"}})

1 Answers
Related