Skip to content

Instantly share code, notes, and snippets.

@vernondegoede
Created February 13, 2019 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vernondegoede/2e99cc68154dfe3a0d507daa5adbf12c to your computer and use it in GitHub Desktop.
Save vernondegoede/2e99cc68154dfe3a0d507daa5adbf12c to your computer and use it in GitHub Desktop.
~/Sites/typescript-api-node/examples/customers typescript*
❯ node list
{ Error: Request failed with status code 401
at createError (/Users/vernon/Sites/typescript-api-node/node_modules/axios/lib/core/createError.js:16:15)
at settle (/Users/vernon/Sites/typescript-api-node/node_modules/axios/lib/core/settle.js:18:12)
at IncomingMessage.handleStreamEnd (/Users/vernon/Sites/typescript-api-node/node_modules/axios/lib/adapters/http.js:201:11)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
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: 'Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM',
'Accept-Encoding': 'gzip',
'Content-Type': 'application/json',
'User-Agent': 'node.js/v8.11.4',
'X-Mollie-User-Agent': 'mollie/2.2.0' },
method: 'get',
apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM',
baseURL: 'https://api.mollie.com:443/v2/',
url: 'https://api.mollie.com:443/v2/customers',
data: undefined },
request:
ClientRequest {
domain: null,
_events:
{ socket: [Function],
abort: [Function],
aborted: [Function],
error: [Function],
timeout: [Function],
prefinish: [Function: requestOnPrefinish] },
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'api.mollie.com',
npnProtocol: undefined,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 9,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'api.mollie.com',
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
_bytesDispatched: 292,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular],
_idleNext: null,
_idlePrev: null,
_idleTimeout: -1,
[Symbol(asyncId)]: 7,
[Symbol(bytesRead)]: 528 },
connection:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'api.mollie.com',
npnProtocol: undefined,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 9,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'api.mollie.com',
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
_bytesDispatched: 292,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular],
_idleNext: null,
_idlePrev: null,
_idleTimeout: -1,
[Symbol(asyncId)]: 7,
[Symbol(bytesRead)]: 528 },
_header: 'GET /v2/customers HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nAuthorization: Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM\r\nAccept-Encoding: gzip\r\nContent-Type: application/json\r\nUser-Agent: node.js/v8.11.4\r\nX-Mollie-User-Agent: mollie/2.2.0\r\nHost: api.mollie.com\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent:
Agent {
domain: null,
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: [Object],
freeSockets: {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
maxCachedSessions: 100,
_sessionCache: [Object] },
socketPath: undefined,
timeout: undefined,
method: 'GET',
path: '/v2/customers',
_ended: true,
res:
IncomingMessage {
_readableState: [Object],
readable: false,
domain: null,
_events: [Object],
_eventsCount: 3,
_maxListeners: undefined,
socket: [Object],
connection: [Object],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers: [Object],
rawHeaders: [Array],
trailers: {},
rawTrailers: [],
upgrade: false,
url: '',
method: null,
statusCode: 401,
statusMessage: 'Unauthorized Request',
client: [Object],
_consuming: true,
_dumped: false,
req: [Circular],
responseUrl: 'https://api.mollie.com:443/v2/customers',
redirects: [],
read: [Function] },
aborted: undefined,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
_redirectable:
Writable {
_writableState: [Object],
writable: true,
domain: null,
_events: [Object],
_eventsCount: 2,
_maxListeners: undefined,
_options: [Object],
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function],
_currentRequest: [Circular],
_currentUrl: 'https://api.mollie.com:443/v2/customers' },
[Symbol(outHeadersKey)]:
{ accept: [Array],
authorization: [Array],
'accept-encoding': [Array],
'content-type': [Array],
'user-agent': [Array],
'x-mollie-user-agent': [Array],
host: [Array] } },
response:
{ status: 401,
statusText: 'Unauthorized Request',
headers:
{ server: 'nginx',
date: 'Wed, 13 Feb 2019 20:12:52 GMT',
'content-type': 'application/hal+json',
'content-length': '209',
connection: 'close',
'www-authenticate': 'Basic realm="Mollie API Key"',
'x-content-type-options': 'nosniff',
'strict-transport-security': 'max-age=31536000; includeSubDomains; preload' },
config:
{ adapter: [Function: httpAdapter],
transformRequest: [Object],
transformResponse: [Object],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus],
headers: [Object],
method: 'get',
apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM',
baseURL: 'https://api.mollie.com:443/v2/',
url: 'https://api.mollie.com:443/v2/customers',
data: undefined },
request:
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,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Object],
connection: [Object],
_header: 'GET /v2/customers HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nAuthorization: Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM\r\nAccept-Encoding: gzip\r\nContent-Type: application/json\r\nUser-Agent: node.js/v8.11.4\r\nX-Mollie-User-Agent: mollie/2.2.0\r\nHost: api.mollie.com\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Object],
socketPath: undefined,
timeout: undefined,
method: 'GET',
path: '/v2/customers',
_ended: true,
res: [Object],
aborted: undefined,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
_redirectable: [Object],
[Symbol(outHeadersKey)]: [Object] },
data:
{ status: 401,
title: 'Unauthorized Request',
detail: 'Missing authentication, or failed to authenticate',
_links: [Object] } } }
~/Sites/typescript-api-node/examples/customers typescript*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment