I'm using node.js v4.6.0 and the latest versions of express, request and body-parser, yet i'm getting an error code which I can't fix, any ideas?
Here's my code:
var express = require('express');
var request = require('request');
var bodyparser = require('body-parser');
var app = express();
app.use(bodyparser.urlencoded({extended: true}))
var webhook = process.env.DISCORD_WEBHOOK;
app.get('/', (req, res) => {
res.sendFile(__dirname + '/index.html');
});
app.post('/webhook', (req, res) =>{
request({
method: 'POST',
url: webhook,
json: {
"content": req.body.msg,
"username": "Potato"
}
});
res.redirect("/");
});
app.listen(80, () => {
console.log("Server Started!");
});
and the error message i'm receiving:
Error: options.uri is a required argument
at Request.init (C:\Users\kingn\node_modules\request\request.js:233:31)
at new Request (C:\Users\kingn\node_modules\request\request.js:129:8)
at request (C:\Users\kingn\node_modules\request\index.js:55:10)
at C:\Users\kingn\index.js:15:5
at Layer.handle [as handle_request] (C:\Users\kingn\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\kingn\node_modules\express\lib\router\route.js:131:13)
at Route.dispatch (C:\Users\kingn\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\kingn\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\kingn\node_modules\express\lib\router\index.js:277:22
at Function.process_params (C:\Users\kingn\node_modules\express\lib\router\index.js:330:12)
Any fixes?