Solved

Node JS JSON question

Posted on 2015-01-19
2
123 Views
Last Modified: 2015-02-24
Hello I have a node module that sends email
-----------------------------------------------------------------

var nodemailer = require("nodemailer");

var app = express();

var smtpTransport = nodemailer.createTransport("SMTP",
    {
    service: "Gmail",
    auth: {
       user: "person@Gmail.com",
        pass: "passval"

    }
});

------------------------------------------------
I would like to save the credentials in a separate json file

File:  security.json

  { "user": "person@Gmail.com",
    "pass": "passval"
  }

-------------------------------------------------

var nodemailer = require("nodemailer");
var credentials = require("./security.json");

var app = express();

var smtpTransport = nodemailer.createTransport("SMTP",
    {
    service: "Gmail",
    auth: {
       user: credentials.user,
        pass: credentials.pass

    }
});
0
Comment
Question by:Charles Baldo
2 Comments
 
LVL 43

Accepted Solution

by:
Rob earned 500 total points
ID: 40559078
What's your question and what is it about your code that doesn't work?

Your code works for me.
0
 

Author Closing Comment

by:Charles Baldo
ID: 40629147
Changing it to a .js file worked for me
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Make check boxes work 8 41
Html split(text) Part2 6 20
Html using "Or" in condition 3 25
Hta File displays dynamic File names 4 44
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question