Wednesday, 26 April 2017

Call Express Route from Reactjs

I'm trying to call express route from Reactjs. Here is a React class method inside which I'm using axios to make a get call to the express route but it doesn't seem to work.

signUp(){
  axios.get('/h')
}

Here is the Nodejs route:

app.get('/h', function(req, res){
  res.sendFile(__dirname + '/html/home.html');
})

Here is something I see in the browser console once the get request has been made:

You are using the in-browser Babel transformer. Be sure to precompile 

your scripts for production - https://babeljs.io/docs/setup/ babel.min.js:24
XHR finished loading: GET "http://localhost:7777/main.jsx". babel.min.js:24
XHR finished loading: GET "http://localhost:7777/h". spread.js:25



via iJade

No comments:

Post a Comment