Skip to content
This repository has been archived by the owner on Dec 30, 2021. It is now read-only.

[BUG] HTTP 400 response status (also tslib dependency is unlisted) #178

Closed
extremq opened this issue Apr 24, 2021 · 3 comments · Fixed by #179
Closed

[BUG] HTTP 400 response status (also tslib dependency is unlisted) #178

extremq opened this issue Apr 24, 2021 · 3 comments · Fixed by #179

Comments

@extremq
Copy link

extremq commented Apr 24, 2021

Describe the bug
I'm using [email protected] (tried imgur@next too) and every time I try uploading an image (tried file and base64, on both versions), I get a Response code 400 (Bad request) error.
Also, tslib is required and I had to install manually it after I installed imgur@next.

To Reproduce
Steps to reproduce the behavior:

const imgur = require('imgur');
imgur.setClientId(process.env.IMGUR_ID)
imgur.setAPIUrl('https://api.imgur.com/3/')
// banner.data is a base64 string
banner = JSON.parse(req.body.banner)
    imgur.uploadBase64(banner.data).then((json) => {
        console.log(json.link)
    }).catch((err) => {
        console.log(err)
    })
HTTPError: Response code 400 (Bad Request)
    at Request.<anonymous> (E:\Projects\site\node-shobi\node_modules\imgur\node_modules\got\dist\source\as-promise\index.js:117:42)    
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  code: undefined,
  timings: {
    start: 1619280530987,
    socket: 1619280530995,
    lookup: 1619280531030,
    connect: 1619280531090,
    secureConnect: 1619280531195,
    upload: 1619280531197,
    response: 1619280531721,
    end: 1619280531731,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 8,
      dns: 35,
      tls: 105,
      request: 2,
      firstByte: 524,
      download: 10,
      total: 744
    }
  }
}

Expected behavior
It should return a 200 response status.

Environment (please complete the following information):

  • Library version [e.g. 1.0.0]: 1.0.0
  • OS [e.g. macOS]: Windows 10
  • NodeJS version [e.g.14.16.0]: 14.16.1

Additional context
As I said, I also tried it with files, tried it with @next and tried multiple function types. It always returned a 400 response status.
The ID I provided is good, I checked it using this site and it successfully uploaded an image.

@extremq extremq added the Bug label Apr 24, 2021
@KenEucker
Copy link
Collaborator

KenEucker commented Apr 25, 2021

Confirmed, I can reproduce this issue:
Screen Shot 2021-04-24 at 4 59 18 PM

(this is not using imgur@next, but [email protected])

UPDATE:
I was able to upload images using a client ID with both uploadUrl and uploadFile.

@kaimallea
Copy link
Owner

whaa that's cray. Thanks for the report! Looking into this now

@kaimallea
Copy link
Owner

🎉 This issue has been resolved in version 1.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants