Home > Software design >  Nodejs Module exports result set
Nodejs Module exports result set

Time:08-17

I am new in Nodejs trying to export site_setting table values using sequelize any help highly appriciated.

Here is my Table setting table here

Blockquote

`const sequelizeConn = require("./database");
var arrResult = new Object();
function getSiteData(){
  settingResult = await sequelizeConn
  .query("SELECT * FROM `site_settings`")
  .then((data) => {
    //  return data;
    data[0].map((res, index) => {
      arrResult[res["setting_title"]] = res["setting_value"];
    });
    // console.log(arrResult);
    return arrResult;
  })
  .catch((err) => {
    console.log(err);
  });

}

module.exports.siteData =getSiteData();


// in other file
var obj = require("./app/config/assets.config");
console.log(obj.SITE_TITLE);  // undefined
`

Blockquote

CodePudding user response:

where is config file bro. i suggest to share your code with github link that will be easy to debug

CodePudding user response:

if you getting your data with your getSiteDate() then use module.exports = getSiteDate() directly and import it using

const sitedata = require('your file path')
  • Related