IssueRaiser

Http ResponseType cannot be set

## I'm submitting a... <!-- Check one of the following options with "x" --> <pre><code> [ ] Regression (a behavior that used to work and stopped working in a new release) [x] Bug report <!-- Please search GitHub for a similar issue or PR before submitting --> [ ] Feature request [ ] Documentation issue or request [ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question </code></pre> ## Current behavior Response type cannot be set for HttpClient methods. ``` const options = {headers: headers, params: params, responseType: 'text'}; return this.http.get(url, options).share(); ``` Would show an error ``` Types of property 'responseType' are incompatible. Type 'string' is not assignable to type '"json"'. ``` ## Expected behavior It is expected that the response type should be exported like ``` export type ResponseType = 'arraybuffer' | 'blob' | 'json' | 'text';; ``` And one would be able to set it using this type. Otherwise the type cannot be changed. ## Environment Angular version: 4.1.1 and still there in 5.0.0-beta.2 as seen here: https://github.com/angular/angular/blob/master/packages/common/http/src/client.ts

Posted by zaiddabaeen on Aug 8, 2017, 3:32 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments

support (Software)

Http ResponseType cannot be set

zaiddabaeenAug 8, 2017, 3:32 PM

## I'm submitting a... <!-- Check one of the following options with "x" --> <pre><code> [ ] Regression (a behavior that used to work and stopped working in a new release) [x] Bug report <!-- Please search GitHub for a similar issue or PR before submitting --> [ ] Feature request [ ] Documentation issue or request [ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question </code></pre> ## Current behavior Response type cannot be set for HttpClient methods. ``` const options = {headers: headers, params: params, responseType: 'text'}; return this.http.get(url, options).share(); ``` Would show an error ``` Types of property 'responseType' are incompatible. Type 'string' is not assignable to type '"json"'. ``` ## Expected behavior It is expected that the response type should be exported like ``` export type ResponseType = 'arraybuffer' | 'blob' | 'json' | 'text';; ``` And one would be able to set it using this type. Otherwise the type cannot be changed. ## Environment Angular version: 4.1.1 and still there in 5.0.0-beta.2 as seen here: https://github.com/angular/angular/blob/master/packages/common/http/src/client.ts

Comments (0)

No comments yet. Start the discussion.

Comment on this issue