Getting "first argument must be a string or Buffer" error
The error is in the request call. To submit the form correctly use
request.post({ url: 'http://localhost:5000/generate', form: formatted }, function(error, response, body) { console.log(body); });
I encourage you to use the npm module request-promise-native:https://github.com/request/request-promise-nativehttps://www.npmjs.com/package/request-promise
var rp = require('request-promise');var options = { method: 'POST', uri: 'http://api.posttestserver.com/post', body: { some: 'payload' }, json: true // Automatically stringifies the body to JSON };rp(options) .then(function (parsedBody) { // POST succeeded... }) .catch(function (err) { // POST failed... });
your body is expected to be Buffer try this, json:true in request option
request.post({ headers: { 'content-type': 'application/x-www-form-urlencoded' }, url: 'http://localhost:5000/generate', body: formatted, json:true }, function(error, response, body) { console.log(body); });