Answer the question
In order to leave comments, you need to log in
How to return data from the server?
Good afternoon.
There is a root
app.get('/auth/', passport.authenticate('auth', { scope: 'user_read' }));
app.get('/auth/callback',
passport.authenticate('auth', {failureRedirect: 'http://localhost:3000/' }),
function(req, res) {
console.log(req.user.data); // <---- мне нужно получить эти данные в компонент реакта
res.redirect('http://localhost:3000/');
}
);
componentWillMount(){
axios.get('http://localhost:5000/auth/').then(data => {
this.setState({
userInfo: data.data
})
console.log(this.state.userInfo)
});
}
var cors = require('cors');
var app = express();
app.use(cors());
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question