Step by Step Create Node.js REST API with SQL Server Database
Why Stack Overflow recommends it
Stack Overflow users link it when they need a worked example of connecting Node.js to SQL Server with the mssql package, either as a starting point or as the tutorial they followed when something broke.
Recommended by 1 people across 1 different months, 2020 to 2021.
What it is
A 39-minute step-by-step tutorial from the NomadCoder channel that builds a Node.js REST API for CRUD operations against a SQL Server database. It uses Node.js, Postman and VS Code, with the full source code on GitHub.
What people said
Recommends Squiba · 2021-09 · Stack Overflow · on “JWT authorization & authentication”
yes, jwt can be used along with any db. you can check the following tutorial for sql [this video] . for jwt with mongoose ( [LINK] )
Cites Dkor · 2020-11 · Stack Overflow · on “ConnectionError: Login failed for user 'user'. SQL authentification failed. Integrated authentication only”
I'm trying to connect to a SQL Server PTC_PROG database. I'm using node.js, the mssql package and Visual Studio Code. I'm following this tutorial: [this video] This is my code: dbconfig.js const config = { user: 'user', password: 'password', server: 'server', database: 'database', options:{ trustedConnection: true, enableArithPort : true, instancename : 'PTC_PROG' }, } module.exports = config; dboperations.js async function getOrders() { try{ let pool = await sql.connect(config); let database = await pool.request().query("SELECT * FROM TABLE"); return database.recordsets; } catch (error){ console.log(error); } } module.exports = { getOrders : getOrders } order.js --------- class Order{ constructo
Cites rodiBoi · 2021-02 · Stack Overflow · on “Nodejs does not receive a response object from SQL Server Insert. recordsets are undefined”
I created a simple function that adds a person into a SQL Server table. The transaction works, and the data gets added to the db, but the response from the database after insertion is not returning the body of the inserted object. The function: async function addPerson(person) { try { let pool = await sql.connect(config) let newPerson = await pool.request() .input('name', sql.VarChar, person.name) .input('last', sql.VarChar, person.last) .input('age', sql.Int, person.age) .execute('InsertPerson') console.log(newPerson) return newPerson.recordsets; } catch { console.log(error) } } The route: // insert person to table router.route('/people').post((request, response) => { let person = { ...requ
Cites NatashaSwan · 2021-12 · Stack Overflow · on “Connecting SQL database on Azure with NodeJS”
I am studying to become a full stack web developer on NodeJS, Express, EJS. Now that I am almost done with my course, I thought I should tackle my dream project which is to create a web app for our local small non-profit library(~6500books). The biggest functionality on the web app is browsing the collection. They are using an SQL database and gave an mbd file to work with. I created an Azure SQL server and database and via several manipulations uploaded the database file there. I see all the tables, can query it, and all looks right there. Now I am trying to figure out how to connect the Azure database to NodeJS (it is the only back-end I am familiar with), so I can fetch data from Azure da