hello , try the code below :
const co =require("zco");
exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) {
co(function*(co_next){
let [err,userData] = yield getExternalLocation(args, co_next);
args.content = args.content +
eejs.require('ep_resources/templates/editbarButtons.ejs', {userData :
**userData** });
return cb();
})()
})
On Sunday, July 2, 2017 at 8:06:46 AM UTC+8, Sushil Kumar Kishan wrote:
>
> I want to return database value in node js and pass as a variable in ejs
> file.
>
> Bellow is the code, Which I used. *it did not return value.*
>
> function getExternalLocation(cb) {
>
> mssql.connect(msSqlSettings, function (err ) {
> if (err) {
> cb(err);
> }
> var getQuery = "SELECT [Title] FROM [dbo].[StyleTemplates] " ;
> //console.log(getQuery);
> var request = new mssql.Request();
> // query to the database and get the data
>
> request.query(getQuery, function (err, rows) {
> mssql.close();
> cb(err, rows);
> });
> });
> } exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) {
>
> var userData = getExternalLocation(args, function(err, rows) {});
> args.content = args.content +
> eejs.require('ep_resources/templates/editbarButtons.ejs', {userData :
> **userData** });
> return cb();
> })
>
> *Userdata* did not return any value;
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/a4f46212-e130-4c0d-9928-ecb44abb8814%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.