Skip to content
New issue

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

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

Already on GitHub? # to your account

promise.json() doesn't throw ParseError #1069

Closed
szmarczak opened this issue Feb 15, 2020 · 2 comments
Closed

promise.json() doesn't throw ParseError #1069

szmarczak opened this issue Feb 15, 2020 · 2 comments
Labels
bug Something does not work as it should ✭ help wanted ✭ regression Something does not work anymore

Comments

@szmarczak
Copy link
Collaborator

szmarczak commented Feb 15, 2020

const got = require('got');

(async () => {
    try {
        // This works as expected
        // await got('https://example.com', {responseType: 'json'}).json();

        // This is incorrect
        await got('https://example.com').json();
    } catch (error) {
        console.log(error.name);
        // Actual: SyntaxError
        // Expected: Got.ParseError
    }
})();
@szmarczak szmarczak added bug Something does not work as it should ✭ help wanted ✭ regression Something does not work anymore labels Feb 15, 2020
@szmarczak
Copy link
Collaborator Author

Added some reproducible code if someone wants to pick this up.

@szmarczak
Copy link
Collaborator Author

Fixed in 4fd1006

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something does not work as it should ✭ help wanted ✭ regression Something does not work anymore
Projects
None yet
Development

No branches or pull requests

1 participant