A
A
Alexander2018-03-11 15:49:50
React
Alexander, 2018-03-11 15:49:50

How to connect react with backend?

Tell me where you can find a detailed tutorial, or at least in what order and what to read in order to understand how to implement authorization through passport js on react and node.
Everything is clear with the backing, but how to attach the react there is not very

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Insolation, 2018-03-11
@IceDevil

how to communicate with api with react

With fetchand with the help of React's lifecycle methods.
class Test extends Component{
  constructor(){
  	super()
    this.state = {
    	someData: []
    }
  }
  
  componentDidMount(){
  	.fetch(//Ваша урла)
    	.then(data => {
      	return data.json
      }).then(data=>{
      //Делаете что-то например перербор и JSX)
      //Обновляете стейт если надо
      }
  } 
  
  render(){}
}

O
Oleg Gamega, 2018-03-11
@gadfi

exactly the same as usual - you have an api, spa communicates with the server through it, which is secondary on the server for the frontend

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question