NodeJS API with Express and SQL Server database

I have a NodeJS API with Express. In my views, I need to call SQL Server functions like in the following example.

const express = require('express');
const router = express.Router();
const { poolPromise } = require('../dbconfig');

router.use(express.json());'/addDesc', async(req, res) => {
    try {
            username= req.body.nomUsager,
            descr = req.body.description ;

        const pool = await poolPromise;
        const result = await pool.request().query(`Select dbo.AddDescr('${nomUsager}', '${descr}')`);


        return res.json({
            // I want to return the value returned by me SQL Functions, but the previous console.log() returned {"": "The function value returned"}. Is it possible to return only the value like that : { "the function value returned" }

    } catch (err) {
        return res.json({

module.exports = router

It works fine, however, how do I get only the result returned by my function rather than an object with an unnamed property? (See my console.log ())

I would like not to use an alias, all my sql function and stored procedure is done

90 thoughts on “NodeJS API with Express and SQL Server database”

Leave a Comment