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

How To Write Better Code In React

React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes.

In this post, I will show you a few tips that will help you become a better React Developer. I will cover a range of things from tooling to actual code style, which can help you improve your skill with React

 

https://blog.bitsrc.io/how-to-write-better-code-in-react-best-practices-b8ca87d462b0

Uncaught Error: To use plugins requiring `addCSS` (e.g. keyframes, media queries), please wrap your application in the StyleRoot component. Component name: in react JS

Uncaught Error: To use plugins requiring `addCSS` (e.g. keyframes, media queries), please wrap your application in the StyleRoot component. Component name:

This error come when you have not added Style root Component and you are using media queries or keyframes , animation.

const yog = (props) => {
    const style = {
        '@media(min-width: 500px)':{
                width:'450px'
        }
    }
........

Then import the style root Component from radium.

import Radium, { StyleRoot } from 'radium';
....

put whole app component in styleroot

render() {
return (
 <StyleRoot>
 
</StyleRoot>