AWS Credential in Nodejs File

Adding via Shared File Credential, specifying profile name:
Shared File Credentials:

[default] ; default profile
aws_access_key_id = 
aws_secret_access_key = 
    
[personal-account] ; personal account profile
aws_access_key_id = 
aws_secret_access_key = 
    
[work-account] ; work account profile
aws_access_key_id = 
aws_secret_access_key = 

Code in nodejs file before any aws calls:

var credentials = new AWS.SharedIniFileCredentials({profile: 'work-account'});
AWS.config.credentials = credentials;

Do a console.log to credentials, if it is empty then it can’t find it

Import directly from .json:
Json file:

{ "accessKeyId": , "secretAccessKey": , "region": "us-east-1" }

nodejs file:

AWS.config.loadFromPath('./config.json');

Directly hard code it in nodejs file:

AWS.config.update({
    accessKeyId: "YOURKEY",
    secretAccessKey: "YOURSECRET",
    sessionToken: "token1",
    securityToken: "token2,
    region: "sa-east-1"   
});

In my experience, sessionToken and securityToke are both needed. Getting credentials from shared file didn’t work.