score:0
issue solved. actually when calling a component and if you don't provide props along with that, we get this error "cannot read property 'token' of undefined". so just pass the props along with the component like {...this.props} and it works well.
score:1
i think you are passing token in wrong way
instead of writing like this
"authorization": "token=" + this.props.login.token,
define like this
"authorization": "bearer " + this.props.login.token,
sample of axios code
axios.post('api_ulr', {
headers: {'authorization': "bearer " + this.props.login.token}
}
).then((response) => {
console.log(response)
}).catch((error) => {
console.log(error)
});
Source: stackoverflow.com
Related Query
- reactjs Cannot read property 'keys' of undefined
- Axios ReactJS - Cannot read property 'setState' of undefined
- Uncaught TypeError: Cannot read property 'bool' of undefined after upgrade reactjs
- ReactJS - Cannot read property 'preventDefault' of undefined
- TypeError: Cannot read property 'presetToOptions' of undefined in webpack-cli with ReactJs
- Reactjs : TypeError: Cannot read property 'propTypes' of undefined
- Uncaught TypeError: Cannot read property 'func' of undefined in reactjs
- TypeError: Cannot read property 'data' of undefined - can't access Object "props" beyond certain level in Reactjs
- ReactJS Cannot read property setState of undefined
- ReactJs - Uncaught TypeError: Cannot read property 'string' of undefined
- ReactJs browser Cannot read property 'keys' of undefined
- TypeError: Cannot read property 'map' of undefined using ReactJs
- Cannot read property 'map' of undefined with REACTJS
- ReactJS - TypeError: Cannot read property '0' of undefined
- ReactJS ES6 function binding - Uncaught TypeError: Cannot read property 'update' of undefined
- ReactJS Cannot read property 'bind' of undefined
- ReactJS -- TypeError: Cannot read property 'name' of undefined
- ReactJS - Cannot read property 'location' of undefined at new Router
- Cannot read property '0' of undefined - stuck with reactjs tutorial
- ReactJS Uncaught TypeError: Cannot read property 'target' of undefined
- Reactjs TypeError: Cannot read property 'style' of undefined
- Cannot read property 'parentNode' of undefined error in ReactJS Redux form
- Apexcharts - ReactJs - real time - Cannot read property 'filter' of undefined
- Cannot read property of undefined in Reactjs
- Cannot read property 'enqueueSetState' of undefined in ReactJS
- TypeError: Cannot read property 'token' of undefined error in reactjs login page
- Uncaught TypeError: Cannot read property 'Checked' of undefined - ReactJS
- Uncaught TypeError: Cannot read property 'props' of undefined in reactJS
- TypeError: Cannot read property 'focus' of undefined in ReactJS
- reactjs - Uncaught TypeError: Cannot read property 'map' of undefined
More Query from same tag
- Test a button of a child component in the parent component
- Using renderOption in MUI's AutoComplete
- Passing more values under same prop name and test it with Jest
- recharts missing ticks or ticks are displayed wrong
- Page content is not loading after redirect - React web app
- react Regex for value after colon in dom
- setState not re-rendering react component inside array
- Cannot read property 'map' of undefined (Help Me)
- How to update certain object in state array based on received key from DOM
- Is there a way to move to a specific index when an item is added in the Angular?
- Materialize and react-router, materialize JS function stops working when changing route
- Error when deploying Shopify React App with Heroku
- dynamic routing with reactjs not working
- How to make MUI Typography without newline?
- JavaScript Cannot set property of undefined
- Chrome credit card autofill not being triggered
- Shopify app with reactjs and nodejs without nextjs?
- React Unique Key Warning Displayed After Uniqueness Established
- React Router Without Changing URL
- Unmount or remove previously opened component before opening again
- fat arrow componentDidMount
- Why useState is not updated in setCnt?
- how to upload image or pdf file with form-data in react-native?
- ReactJS - dynamically update jsonschema dropdown
- How to set a FILE Name while downloading a file from FileReader?
- A simple "Hello World" in React.js not working
- Why is React Js called as Single Page Application
- how to solve this error You may need an appropriate loader to handle this file type
- Footer overlapping content when trying to make it stay at the bottom of the page
- how do i change state on this navbar