-
-
Couldn't load subscription status.
- Fork 971
Closed
Labels
bugSomething does not work as it shouldSomething does not work as it shouldexternalThe issue related to an external projectThe issue related to an external project
Description
I wasted a lot of time debugging and turned out in the end to be because of electron.net. I should have known better than to trust when documentation says it's compatible...
Latest master of Got.
// x.js
'use strict';
const fs = require('fs');
const electron = require('electron');
const got = require('got');
const FormData = require('form-data');
const endpoint = 'https://upload.giphy.com/v1/gifs';
const form = new FormData();
form.append('api_key', 'dc6zaTOxFJmzC');
form.append('file', fs.createReadStream(process.argv[2]));
electron.app.on('ready', () => {
got.post(endpoint, {body: form, useElectronNet: false})
.then(x => {
console.log(x.body)
})
.catch(console.error);
});❯ electron x.js somgif.gif
{ HTTPError: Response code 401 (Unauthorized)
at stream.catch.then.data (/Users/sindresorhus/dev/oss/got/index.js:176:13)
at process._tickCallback (internal/process/next_tick.js:103:7)
name: 'HTTPError',
host: 'upload.giphy.com',
hostname: 'upload.giphy.com',
method: 'POST',
path: '/v1/gifs',
protocol: 'https:',
url: 'https://upload.giphy.com/v1/gifs',
statusCode: 401,
statusMessage: 'Unauthorized',
headers:
{ connection: [ 'keep-alive' ],
'content-length': [ '120' ],
'content-type': [ 'application/json' ],
date: [ 'Fri, 26 May 2017 06:57:47 GMT' ],
server: [ 'nginx/1.8.0' ],
'x-robots-tag': [ 'noindex' ] } }
But if I set {useElectronNet: false} option it works:
{"data":{"id":"xUPGcpzBUNI6LfbgeA"},"meta":{"status":200,"msg":"OK","response_id":"5927d27a70f352831c34e527"}}
I could use some help debugging where exactly it breaks so we can report it to Electron.
NetOpWibby
Metadata
Metadata
Assignees
Labels
bugSomething does not work as it shouldSomething does not work as it shouldexternalThe issue related to an external projectThe issue related to an external project