TastyWorks icon indicating copy to clipboard operation
TastyWorks copied to clipboard

Im a new coder

Open Ianfinn1994 opened this issue 4 years ago • 5 comments

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;

Ianfinn1994 avatar Feb 16 '21 07:02 Ianfinn1994

Bro?

Ianfinn1994 avatar Feb 18 '21 15:02 Ianfinn1994

@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.

ffalor avatar Mar 09 '21 03:03 ffalor

I would like to correspond if it is ok, boss.

Ianfinn1994 avatar Mar 09 '21 03:03 Ianfinn1994

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

elescondite avatar Jun 11 '21 20:06 elescondite

Thank you, man. If we could correspond more, I would appreciate the mentoring.

Ianfinn1994 avatar Jul 23 '21 02:07 Ianfinn1994