javascriptnode.jsexpresscallbackdribbble-api

Express.js req.body is undefined when getting callback


I'm trying to receive a callback from the Dribbble Auth API. The Authentication process is working fine until I'm trying to fetch the response data with NodeJS.

My Callback-URL is http://localhost:8080/callback A callback url looks like this http://localhost:8080/callback?code=11ee328ab7935bd7240cbff0a2d0b8c93e96547e0a3&state=aoksdmSAOKDm

I'm using body-parser and multer.

var express = require("express");
var multer = require("multer");
var bodyParser = require("body-parser");
var cookieParser = require("cookie-parser");
var upload = multer({ storage: multer.memoryStorage() });

var app = express();

app.use(cookieParser());
app.use(bodyParser.urlencoded({
  extended: true
}));
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, "../webapp/")));

app.get("/callback",  upload.single("code"), (req,res) => {
  console.log(req.body);
  res.send()
}

The response in the console is undefined


Solution

  • the query isn't in req.body with a GET request. you have to do:

    req.query