TastyWorks
TastyWorks copied to clipboard
Im a new coder
I have never done anything in node. Im trying to fill in my account info so the code can run, i may have edited the wrong part. Do i delete TASTY_USERNAME and TASTY_PASSWORD?
'use strict';
const TastyWorks = require('../lib/index'); const credentials = { username: process.env.TASTY_USERNAME, password: process.env.TASTY_PASSWORD };
let TASTY_ACCOUNT_ID;
// Set the username and password TastyWorks.setUser(credentials);
// Before making any calls, get the session-token via the authorization endpoint TastyWorks.authorization() .then(token => { // Set the authorization in the headers TastyWorks.setAuthorizationToken(token); console.log('Session is active, continue with other calls.'); return true; }) .then(() => TastyWorks.accounts()) .catch(err => console.log(err.status)) .then(accounts => { TASTY_ACCOUNT_ID = accounts[0]['account-number']; TastyWorks.setUser({accounts}); }) .then(() => { console.log('======= USER OBJECT ======='); console.log(TastyWorks.getUser()); })
Also, when i edit here by let TASTY_ACCOUNT_ID; i get an error.
How do i run the code, and where do i enter my account info. Its confusing. Do i edit
const TastyWorks = require('../lib/index'); const credentials = { username: process.env.TASTY_USERNAME, password: process.env.TASTY_PASSWORD };
let TASTY_ACCOUNT_ID;
Bro?
@Ianfinn1994 Not my code, but you are correct based on the sample you will edit these values.
Here is the example:
const credentials = {
username: process.env.TASTY_USERNAME,
password: process.env.TASTY_PASSWORD
};
This is what it would look like:
const credentials = {
username: 'lanfin1994',
password: 'SecretPassword1234'
};
Make sure the values you put in for username, password are in the quotes don't delete them.
I would like to correspond if it is ok, boss.
The code is looking for environment variables (process.env). It's a pretty standard thing to do in a lot of languages that makes the code more secure and portable.
So in your shell you want to:
set TASTY_USERNAME=lanfin1994
set TASTY_PASSWORD=SecretPassword1234
Thank you, man. If we could correspond more, I would appreciate the mentoring.