Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Prereqs
- npm install dotenv
- ## Cloudant (DB)
- Before querying the cloudant db, Create a cloudant DB and follow the steps below,
- create a .env file with your Cloudant credentials in the root directory.
- ```
- cloudant_username=myaccount # Replace myaccount with your account name
- cloudant_password='secret' # Replace secret with your password
- ```
- or on a terminal
- ```
- echo "/.env" >> .gitignore # Do not track .env in the revision history
- echo "cloudant_username=myaccount" > .env # Replace myaccount with your account name
- echo "cloudant_password='secret'" >> .env # Replace secret with your password
- ```
- ### Credentials in app.js
- require('dotenv').load();
- // Load the Cloudant library.
- var Cloudant = require('cloudant');
- var username = process.env.cloudant_username;
- var password = process.env.cloudant_password;
- // Initialize the library
- var cloudant = Cloudant({
- account: username,
- password: password
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement