POST请求res.redirect()不起作用

时间:2017-11-18 18:50:37

标签: javascript node.js forms express post

这是我的邮寄路线。当我提交表格时,它基本上就会停止。邮件正在发送给服务器,但响应(重定向)没有被发送回客户端。

app.post('/signup', function(req, res) {
var customer = req.body.customer;
var newCustomer = {
    "first_name": customer.first_name,
    "last_name": customer.last_name,
    "email": customer.email,
    "password": customer.password,
    "phone": customer.phone,
    "address": `${customer.address} ${customer.appt}`,
    "city": customer.city,
    "state": customer.state,
    "zip": customer.zip,
    "country": "US",
    "gateway_type": "PayWhirl Test Gateway",
    "gateway_id": 4133,
    "currency": "USD",
    "metadata": customer.referral
}

paywhirl.Customers.createCustomer(newCustomer, function() {
    if(err) {
        console.log(err);
        res.redirect('/', {err: err});
    } else {
        console.log('customer created!');
        res.redirect('/', {first_name: customer.first_name});
    }
});
})

以下是正在调用的paywhirl函数:

createCustomer: function(data, cb) {
    options.path = "/create/customer";
    options.method = "POST";

    utils.pwPOST(options, data, cb);

},

0 个答案:

没有答案
相关问题