I've written a node.js purger and I need to bring in environmental variables.
How to do this correctly? I've tried a few methods from how I remember doing this in Rails, ways in the past, and trying to dig it out online but I haven't gotten it to work yet.
Thanks!
My latest try:
var clientToken = process.env.AKAMAI_CLIENT_TOKEN;
var clientSecret = process.env.AKAMAI_ACCESS_TOKEN;
var accessToken = process.env.AKAMAI_SECRET;
var host = process.env.AKAMAI_HOST;
var config = {
clientToken: clientToken,
clientSecret: clientSecret,
accessToken: accessToken,
host: host,
queue: "default"
};
many thanks!
add-on: error:
readline.js:925
throw err;
^
TypeError: Cannot read property 'replace' of null
at Authenticator.makeDataToSign (/Users/homeImac/purger/node_modules/akamai-ccu-purge/src/auth.js:88:23)
at Authenticator.generateSignature (/Users/homeImac/purger/node_modules/akamai-ccu-purge/src/auth.js:100:25)
at Authenticator.generateAuthHeaderForRequest (/Users/homeImac/purger/node_modules/akamai-ccu-purge/src/auth.js:122:24)
at Purger.purgeObjects (/Users/homeImac/purger/node_modules/akamai-ccu-purge/src/purger.js:30:39)
at /Users/homeImac/purger/node_modules/akamai_purge/newPurge.js:28:10
at /Users/homeImac/purger/node_modules/akamai_purge/getUrl2.js:9:14
at /Users/homeImac/purger/node_modules/prompt/lib/prompt.js:316:32
at /Users/homeImac/purger/node_modules/utile/node_modules/async/lib/async.js:142:25
at assembler (/Users/homeImac/purger/node_modules/prompt/lib/prompt.js:313:9)
at /Users/homeImac/purger/node_modules/prompt/lib/prompt.js:322:32
I'll add my bash code just to cover all bases as well. It's still not working for me.
export AKAMAI_CLIENT_TOKEN="dfghdfhdfhgfhdfghdfghfghfdghfg"
export AKAMAI_ACCESS_TOKEN="fhdfghdfghdfhdfghfhfghdfg"
export AKAMAI_SECRET="dfhfdghdfhgfdhgfhdhgfhdgfh="
export AKAMAI_HOST="fghghdfhdhhgfdhgfhdghdfgf.purge.akamaiapis.net"
That's all i need in the bash file right? There's an = at the end of the 3rd line. That shouldn't cause any issues right? Thanks for the help folks!
Additional note: I added quotes around the values thanks to a tip I received below. I can still console.log the info just fine but I still receive this error.