Got: Right-hand side of 'instanceof' is not an Object

Created on 11 Jan 2019  路  7Comments  路  Source: sindresorhus/got

Describe the bug

  • Node.js version: 10.12.0
  • OS & version: Linux 4.13.0-41-generic 46~16.04.1-Ubuntu SMP Thu May 3 10:06:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

I'm using CRA (Create React App) version 2, customized-cra, and mobx, when I try to run simple code, I got an error.

Actual behavior

Uncaught (in promise) TypeError: Right-hand side of 'instanceof' is not an object
    at normalize (normalize-arguments.js:188)
    at got (create.js:37)

Expected behavior

Should return html body.

Code to reproduce

codesandbox: https://codesandbox.io/s/n4q68m36ll

code:

try {
      console.log(this.resturl.spinnerList)
      const response = await got('sindresorhus.com')
      console.log(response.body)
    } catch (error) {
      console.log(error)
    }
  • [x] I have read the documentation.
  • [x] I have tried my code with the latest version of Node.js and Got.

Most helpful comment

https://github.com/sindresorhus/ky is a good alternative for browsers

All 7 comments

TypeError: Right-hand side of 'instanceof' is not an object
    at normalize (node_modules/got/source/normalize-arguments.js:137:68)
    at got (node_modules/got/source/create.js:32:28)

https://github.com/sindresorhus/got/blob/91c0607b21f85adc568a0d182b47483e59855f95/source/normalize-arguments.js#L137

I ran require('url').URLSearchParams in the sandbox. It gives undefined. On my local machine it works perfectly.

@szmarczak
I'm not running my code in the codesandbox, but also in my local machine too.I just put an example link in order to add a working project example (not just code / screenshot).

So, please reopen this issue.

@oknoorap You're running it through webpack. As metioned in the documentation, Got doesn't support browsers.

@szmarczak okay i see. thank you.

https://github.com/sindresorhus/ky is a good alternative for browsers

@rohmanhm thanks dude..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alanzhaonys picture alanzhaonys  路  4Comments

darksabrefr picture darksabrefr  路  3Comments

tkoelpin picture tkoelpin  路  3Comments

astoilkov picture astoilkov  路  3Comments

dominusmars picture dominusmars  路  3Comments