Node.js error: Route.post() requires a callback function but got a [object Object]

Node.js error: Route.post() requires a callback function but got a [object Object]

我是 运行 一个 Node.js 脚本,使用这些指令 https://stripe.com/docs/connect/standard-accounts#token-request

从 Stripe 获得 JSON 响应

但是,我在使用以下代码时遇到以下错误:

Error: Route.post() requires a callback function but got a [object Object]

代码

var app = express();
var stripe = require('stripe')('sk_test_XXXXXXXXXXXXXXXX')
var bodyParser = require('body-parser')
var request = require('request')

app.post('/ptaccountid',(req,res) => {

  var authCode = req.body.code;

  app.post('https://connect.stripe.com/oauth/token', {
    form: {
     client_secret: "sk_test_XXXXXXXXXXXXXXXX",
     code: authCode,
     grant_type: "authorization_code",
    }
 }, function(err, response, body) {
    if (!err && response.statusCode == 200) {
      console.log(body)
  }
});
}); 

您应该使用 request.post 而不是 app.post

检查下面的代码,

app.post('/ptaccountid',(req,res) => {
    var authCode = req.body.code;

    request.post('https://connect.stript.com/oauth/token', {
          form: {
           client_secret: "sk_test_XXXXXXXXXXXXXXXX",
           code: authCode,
           grant_type: "authorization_code",
          }
        }, function(err, response, body) {
          if (!err && response.statusCode == 200) {
            console.log(body)
        }
    });
}); 

希望对您有所帮助!