javascript - Issue exporting module NodeJS -


i have directory structure:

  • app/router.js
  • app/oauth2-home-client/oauth2-client.js

and sources:

app/oauth2-home-client/oauth2-client.js

    //some code      exports.bearer = {              authenticate : passport.authenticate('bearer', { session : false }),              initialize : passport.initialize()              // session : passport.session()     }; 

app/router.js

var oauth2 = require('./oauth2-home-client/oauth2-client');  console.log(json.stringify(oauth2.bearer));  //some code 

when print oauth2.bearer (and oauth2, too) content, {}. doing wrong?

thanks.

your code:

exports.bearer = {   authenticate : passport.authenticate('bearer', { session : false }),   initialize : passport.initialize()   // session : passport.session() }; 

will result in:

exports.bearer = {   authenticate :undefined,   initialize : undefined }; 

because both passport.authenticate , passport.initialize return undefined.

and keys having value undefined omitted json.stringify.

[...]if undefined, function, or symbol encountered during conversion either omitted (when found in object) or censored null (when found in array).[...]


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -