Error : Argument of type ‘{ headers: HttpHeaders; responseType: string; }’ is not assignable to parameter of type ‘{ headers?: HttpHeaders | …….

If You have this error in angular request for response type “text”,

Argument of type ‘{ headers: HttpHeaders; responseType: string; }’ is not assignable to parameter of type ‘{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: “bod

y”; params?: Ht…’.

You need to set header from ….

    let headers = new HttpHeaders({

        ‘Content-Type’: ‘application/json’,

        ‘Authorization’: window.sessionStorage.token

      });

      let authHttpOptions = {

       headers : headers,

        responseType: ‘text’

      }

       this.http.post(url, param, authHttpOptions)

          .subscribe(..)

to

 this.http.post(url, param, {

          headers: new HttpHeaders({‘Content-Type’: ‘application/json’, ‘Authorization’: window.sessionStorage.token}),

          responseType : ‘text’

 })

          .subscribe( …) 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s