okay whenever run node.js code (for discord webhooks) , html, gives me error "cannot post" whenever send request here's html code:
<html> <head> <title>test</title> </head> <body> <form method="post" action="/discordy"> <input type="text" name="msg" placeholder="put message here" /> <br> <input type="submit" name="submit" value="send message" /> </form> </body> </html>
and here's node.js code:
var express = require('express'); var request = require('request'); var bodyparser = require('body-parser'); var app = express(); app.use(bodyparser.urlencoded({extended: true})); var webook = 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": "welcome!" } }); res.redirect('/'); }); app.listen(80, () => { console.log("server started!"); });
when run code ^, no errors, when run localhost. error
help appreciated, thank you.
Comments
Post a Comment