Search code examples
angularrxjshttpclient

Cant set option observe:'responce' for httpClient


I am trying to create a service for downloading blob files, but i need headers of responce. So i need to set observe option to responce. When i'am trying to do it like in angular docs:

return this.http
      .post(urlCompleted, body, {
        headers,
        observe: 'responce',
        responseType: 'blob',
      })

i get an error:

The last overload gave the following error.
  Type '"responce"' is not assignable to type '"body" | undefined'.
    Type '"blob"' is not assignable to type '"json" | undefined'.

here Angular Post cant set observe to response people sugests to set options inline, but as you see its doesent working.

I also tried to do it like this:

return this.http
  .post(urlCompleted, body, {
    headers,
    observe: 'responce' as 'body',
    responseType: 'blob',
  })

and yeah, typescript is happy now, but i get another error in browser: ERROR Error: Unreachable: unhandled observe type responce}

Soo, what im doing wrong?


Solution

  • The answer was simple, i needed to use "response" not "responce". Time to study grammar.

    Thanks to @R.Richards from comments.