Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sequelize with mysql nodejs

const express = require(“express”);
const bodyParser = require(“body-parser”);
const cors = require(“cors”);

const app = express();

Var corsOptons = {
	origin: “http://localhost:8080/”
		};
app.use (cors(corsOptions));

// parse requests of content-type - application/json

app.use (bodyParser.json());
// parse requests of content-type - application/x-www-form-urlencoded

app.use (bodyParser.urlencoded({extended:true}));

//simple route
app.get (“/”, (req, res) => {
res.json({message: “Welcome to Turing.com”});
});

// set port, listen for requests
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log (‘Server is running on port $(PORT).’ );
});
Source by www.turing.com #
 
PREVIOUS NEXT
Tagged: #sequelize #mysql #nodejs
ADD COMMENT
Topic
Name
4+8 =