My First Playground

node v18.11.0
version: 4.0.2
endpointsharetweet
This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
var tonicExpress = require("@runkit/runkit/express-endpoint/1.0.0") // Just provide the exports object to the tonicExpress helper var app = tonicExpress(module.exports) var bodyParser = require('body-parser'); app.use(bodyParser.urlencoded({ extended: false })); app.get("/", (req, res) => { res.type("text/plain"); res.send("Hello World!"); }); app.get("/200", (req, res) => { var formData = { "status" : "200", "message" : "Everything works here!" }; res.type("application/json"); res.send(formData); }); app.get("/500", (req, res) => { var formData = { "status" : "500", "message" : "Nothing works here!" }; res.type("application/json"); res.send(formData); }); app.get("/codes/:code", (req, res) => { var code = req.params.code; var message = ''; if (code == "200") { message = "Success"; } else if (code == "500") { message = "Failure"; } var formData = { "status" : req.params.code, "message" : message }; res.type("application/json"); res.send(formData); }); app.get("/link", (req, res) => { var data = { "status" : "200", "message" : "https://www.nytimes.com" }; res.type("application/json"); res.send(data); }); app.get("/session_data", (req, res) => { console.log(req.body); var data = { "status" : "200" }; res.type("application/json"); res.send(data); });
Loading…

no comments

    sign in to comment