Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda