Hello Guys, need some help.
Im following this tutorial: Headless newsletter with Ghost
When the above code -which requires the Ghost admin-api- , is run on AWS Lambda:
I get an error i think is related to the admin API (maybe im using the wrong Node.js version?):
{
"errorMessage": "Cannot read property 'split' of undefined",
"errorType": "TypeError",
"stackTrace": [
"token (/var/task/node_modules/@tryghost/admin-api/lib/token.js:4:30)",
"makeApiRequest (/var/task/node_modules/@tryghost/admin-api/lib/index.js:285:37)",
"makeResourceRequest (/var/task/node_modules/@tryghost/admin-api/lib/index.js:245:16)",
"Object.browse (/var/task/node_modules/@tryghost/admin-api/lib/index.js:127:20)",
"handler (/var/task/index.js:15:47)"
]
}
I shipped the code to AWS Lambda using Node.js 8.16 and the runtime over there (on Lambda) is Node.js 8.10
Does that matters?
Thanks in advanced.
It looks like your admin key might not be functioning properly - the cannot read property 'split' of undefined
error is coming from the token generator of the admin api.
You might want to check that the token in GHOST_ADMIN_KEY is of the proper format. Good luck!
1 Like
yes i was following the tutorial and did not realized that the ghost_host variable for another Lambda function which uses the content-api is different for the ghost_host variable of the admin-api which must be something like: https://mydomain.com/admin/ghost/api/2.25.9/admin
According to admin-api docs: here
Now i am getting this error:
{
"errorType": "Error",
"errorMessage": "GhostAdminAPI Config Invalid: @tryghost/admin-api requires a \"url\" without a trailing slash like \"https://site.com\" or \"https://site.com/blog\"",
"stack": [
"Error: GhostAdminAPI Config Invalid: @tryghost/admin-api requires a \"url\" without a trailing slash like \"https://site.com\" or \"https://site.com/blog\"",
" at GhostAdminAPI (/var/task/node_modules/@tryghost/admin-api/lib/index.js:58:15)",
" at new GhostAdminAPI (/var/task/node_modules/@tryghost/admin-api/lib/index.js:10:16)",
" at Object.<anonymous> (/var/task/index.js:7:15)",
" at Module._compile (internal/modules/cjs/loader.js:776:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)",
" at Module.load (internal/modules/cjs/loader.js:653:32)",
" at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
" at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
" at Module.require (internal/modules/cjs/loader.js:690:17)",
" at require (internal/modules/cjs/helpers.js:25:18)"
]
}
The value of GHOST_HOST enviromental variable is:
https://mydomain.com/admin/ghost/api/2.25.9/admin/
any ideas?
Oh sorry for my STUPIDITY. Turns out i did not had any GHOST_ADMIN_KEY declared as env variable at all on the AWS Lambda panel.
1 Like