0
votes

Currently I'm trying to set up a project featuring Spotify's Web API. I'm trying to authenticate the user, I have the Client ID and the scopes, but the request params are showing up undefined in Node.

I have a "Log in with Spotify" page that sends the user to the Spotify auth page, when they successfully auth they get sent back to my /callback URI, but I cannot reference the request param for the spotify code from Node. I can see it in the browser window under the correct "code" name.

The callback handler in Node:

app.get('/callback', function(req, res){
  console.log('Code: ' + req.params.code);
  res.sendFile(__dirname + '/auth.html');
});

When the handler runs I see Code: undefined, but when I look at the browser URL I see /callback?code=(code here). I'm not sure what I'm misunderstanding on the Node side, as I assumed the request params would be available by the route handler before sending the HTML response. Thoughts?

1

1 Answers

0
votes

req.params is wrong. req.query is correct.