Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Example->
Page 1->
<pre lang="Javascript"><pre>import React from "react";

class Token extends React.Component {

	state = {
		token: [],
		DataisLoaded: false
	};

	componentDidMount() {
	 
	fetch("{api}", {
				method: 'POST',
				headers: {  
					'Content-Type' : 'application/json',
					'Authorization' : 'Basic '
				}
			  })
			.then((res) => res.json())
			.then((json) => {
				this.setState({
					token: json,
					DataisLoaded: true
				});
			})
			
	}
	render() {
		<big>let varToken = this.state.token.access_token</big>

		return (
			<>
			</>
		)
}

}

export default Token;



Page->
now how to get the value of varToken in another page/component in react js or if I want the value of the state
{this.state.token.access_token}


What I have tried:

Tried importing the page 1 in 2nd page but not getting the value of let
Posted
Comments
Priyanshu Sharma 2021 1-Nov-21 0:27am    
Anyone having problem understanding the question please comment

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900