Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
add sql databas data array to localstorage

I have tried to add recordset of database to local storage to be used in browser.

I have tested to add the recordset to localstorage and return it back to the storednames array

//Connect to database
var sql = require("mssql");// appear undefined in browser 

var config = {
user: '****',
password: '****',
server: '****',
databse:'****',
port: 1433,
options: {
    trustedConnection: true,
    trustServerCertificate: true
  },
};

let test = [{field:"ddd"},{field:"AAA"}]; // appear undefined when called in browser 


sql.connect(config, function (err) {
    if (err) console.log(err);
    // create Request object
    var request = new sql.Request();
    // query to the database and get the records
    request.query("select * from Test ", function (err, recordset) {
        if (err) console.log(err)
        // write the records in console.log
        console.log(recordset) 
        //add recordset to localstorage then get array back from localstorage 
        localStorage.setItem("recordset", JSON.stringify(recordset));
        var storedNames = JSON.parse(localStorage.getItem("recordset"));
        console.log(storedNames);//it appears error 


    });
});

but when console.log the storedNames it appears an error in terminal..

Also another thing I did not understand. when I tried to open the browser, it shows in developer tool (require is undefined.. ) in server.js file, also tried to call (let Test) inside browser consule, always show undefined.

can any one please help me to understand what I am exactly missing.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!