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
Add options to customize parsing/stringifying JSON #1298
Conversation
@Giotino |
IMO this is good to merge. |
Actually I'm having second thoughts. This also adds more complexity. What's against having const {body} = await got(...);
const parsed = JSON.parse(body, parser); I don't think like this change is really necessary. |
I thought so, but with It's not a "must have" feature, but since someone showed interest in that it means that it might be nice to have. Also I don't think it adds that much complexity. |
Maybe we should ear more opinions before proceeding. |
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
In our case we have ~50 methods that call API via Same thinking as why got.extend function and hooks exist in the first place. Without it - it'll need copy/pasting the hooks to every usage. |
Hmm... @kirillgroshkov is right. So |
Examples needs to be fixed/improved. @sindresorhus @szmarczak const got = require('got');
await got(); const got = require('got');
(async () => {
await got();
})(); await got(); I think that |
@sindresorhus has said a while ago that these examples should be 100% functional. Copy-paste and it should work. |
https://github.com/sindresorhus/got/pull/1298/files#r433074774 still needs to be resolved. |
That would be great as a separate PR. We should normalize to always require Got and always use the async IIFE. |
Yeah, I'm aware of it, I was kinda busy so I delayed it a bit. |
Co-authored-by: Szymon Marczak <36894700+szmarczak@users.noreply.github.com>
Co-authored-by: Szymon Marczak <36894700+szmarczak@users.noreply.github.com>
Excellent 👌 |
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com> Co-authored-by: Szymon Marczak <36894700+szmarczak@users.noreply.github.com>
Custom function to parse JSON responses.
Checklist
Fixes #1274