@Kevin Thanks again.
I’m running the Token Generation Javascript Example (Found on Ghost Admin API Doc) in an express js docker container accessible on http://localhost:3000.
My Ghost Blog is set up and running on http://localhost:2368.
When I hit the express service at http://localhost:3000/ghost-post it runs this Token Generation Javascript Example.
When I check the error logs I get the below error
{ Error: connect ECONNREFUSED 127.0.0.1:2368
at Object.exports._errnoException (util.js:1050:11)
at exports._exceptionWithHostPort (util.js:1073:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 2368,
config:
{ adapter: [Function: httpAdapter],
transformRequest: { '0': [Function: transformRequest] },
transformResponse: { '0': [Function: transformResponse] },
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus],
headers:
{ Accept: 'application/json, text/plain, */*',
Authorization: 'Ghost eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjVjODU1ZTAwYmM1MzNlMDAwMWJmZjkwNyJ9.eyJpYXQiOjE1NTI0MTQ5NjIsImV4cCI6MTU1MjQxNTI2MiwiYXVkIjoiL3YyL2FkbWluLyJ9.3JRLTL-xr7qWAdwTGakwcOQL114_9eSgn-im1V3FeX8',
'User-Agent': 'axios/0.18.0' },
method: 'get',
url: 'http://localhost:2368/ghost/api/v2/admin/posts/?limit=1',
data: undefined },
request:
Writable {
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object] },
writable: true,
domain: null,
_events:
{ response: [Function: handleResponse],
error: [Function: handleRequestError] },
_eventsCount: 2,
_maxListeners: undefined,
_options:
{ maxRedirects: 21,
maxBodyLength: 10485760,
protocol: 'http:',
path: '/ghost/api/v2/admin/posts/?limit=1',
method: 'get',
headers: [Object],
agent: undefined,
auth: undefined,
hostname: 'localhost',
port: '2368',
nativeProtocols: [Object],
pathname: '/ghost/api/v2/admin/posts/',
search: '?limit=1' },
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function],
_currentRequest:
ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedHeader: {},
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Object],
connection: [Object],
_header: 'GET /ghost/api/v2/admin/posts/?limit=1 HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nAuthorization: Ghost eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjVjODU1ZTAwYmM1MzNlMDAwMWJmZjkwNyJ9.eyJpYXQiOjE1NTI0MTQ5NjIsImV4cCI6MTU1MjQxNTI2MiwiYXVkIjoiL3YyL2FkbWluLyJ9.3JRLTL-xr7qWAdwTGakwcOQL114_9eSgn-im1V3FeX8\r\nUser-Agent: axios/0.18.0\r\nHost: localhost:2368\r\nConnection: close\r\n\r\n',
_headers: [Object],
_headerNames: [Object],
_onPendingData: null,
agent: [Object],
socketPath: undefined,
timeout: undefined,
method: 'GET',
path: '/ghost/api/v2/admin/posts/?limit=1',
_ended: false,
res: null,
aborted: undefined,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
_redirectable: [Circular] },
_currentUrl: 'http://localhost:2368/ghost/api/v2/admin/posts/?limit=1' },
response: undefined }
If I curl run below, its works as a bash command
curl -H "Authorization: 'Ghost $token'" http://localhost:2368/ghost/api/v2/admin/posts/?limit=1