Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requestAsBrowser parses HTML as JSON with json: false #1028

Closed
metalwarrior665 opened this issue May 13, 2021 · 1 comment · Fixed by #1029
Closed

requestAsBrowser parses HTML as JSON with json: false #1028

metalwarrior665 opened this issue May 13, 2021 · 1 comment · Fixed by #1029
Labels
bug Something isn't working.

Comments

@metalwarrior665
Copy link
Member

Describe the bug
Passing a boolean json param forces JSON parsing even if that boolean is false

To Reproduce
const response = await Apify.utils.requestAsBrowser({
url: 'http://www.realtor.com/realestateandhomes-detail/3713-Ohio-Ave_Tampa_FL_33611_M50711-30877',
json: false
});

Crashes with

RequestError: Unexpected token < in JSON at position 0 in "https://www.realtor.com/realestateandhomes-detail/3713-Ohio-Ave_Tampa_FL_33611_M50711-30877"
2021-05-13T19:53:21.852Z       at Object.parseBody [as default] (/usr/src/app/node_modules/got/dist/source/as-promise/parse-body.js:22:15)
2021-05-13T19:53:21.854Z       at Request.<anonymous> (/usr/src/app/node_modules/got/dist/source/as-promise/index.js:72:61)
2021-05-13T19:53:21.856Z       at JSON.parse (<anonymous>)
2021-05-13T19:53:21.858Z       at parseJson (/usr/src/app/node_modules/got/dist/source/index.js:118:35)
2021-05-13T19:53:21.860Z       at Object.parseBody [as default] (/usr/src/app/node_modules/got/dist/source/as-promise/parse-body.js:11:48)
2021-05-13T19:53:21.862Z       at Request.<anonymous> (/usr/src/app/node_modules/got/dist/source/as-promise/index.js:72:61)
2021-05-13T19:53:21.864Z       at processTicksAndRejections (node:internal/process/task_queues:96:5)

Without the json field it works

@B4nan
Copy link
Member

B4nan commented May 14, 2021

1.2.1 is out with the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants