octokit.js: Unexpected end of JSON input
I’m pretty sure I’m doing something wrong here, but I’ve exhausted what it is.
const octokit = require('@octokit/rest')({
debug: true,
host: 'github.<company domain>.com',
pathPrefix: '/api/v3'
});
octokit.authenticate({
type: 'token',
token: '<personal access token with all scopes'
});
octokit.orgs.get({org: '<valid org>'}, (error, result) => {
console.log(error);
});
Output:
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at IncomingMessage.response.on (./node_modules/@octokit/rest/lib/request/request.js:79:31)
at IncomingMessage.emit (events.js:164:20)
at endReadableNT (_stream_readable.js:1054:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)```
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 22 (11 by maintainers)
My suspect was right. When I went through the source code and changed the
baseUrlto my hosted endpoint, the data comes back correct without errors.Here and here