coinbase / coinbase-commerce-node

Coinbase Commerce Node
MIT License
148 stars 54 forks source link

req.on() never called in webhook #23

Closed basit1327 closed 4 years ago

basit1327 commented 5 years ago

As code provided in the example of webhook.js i created a ngrok address and send a test request , and yes test request received but as you write a middleware for rawBody in which two events are defined

   req.on('data', function (chunk) {
        console.log('step 2:');
        data += chunk;
    });
    req.on('end', function () {
        req.rawBody = data;
        next();
    });

none of the above method called , so req.rawBody remain undefined

basit1327 commented 5 years ago

instead if you use req,body every thing there i think there is no need for these callbacks

oa-coinbase commented 4 years ago

Just tested, seems to work fine. rawBody function is a custom body parser but you can use any you'd like. Perhaps this may help https://expressjs.com/en/4x/api.html#req.body