Ky: afterResponse hooks not fired if await ky directly

Created on 31 Jan 2019  路  1Comment  路  Source: sindresorhus/ky

As discussed in Pr #93:
afterResponse hooks are not executed for the following code:

const response = await ky.get('https://example.com', {
    hooks: {
        afterResponse: [
             response => {
                 // This won't get called
             }
         ]
     }
});

const data = await response.json();

I know this is not how ky is supposed to be used, but it's easy to fall into this and see that everything is working, except the hooks.

bug help wanted

Most helpful comment

Confirmed. From what I can see, the underlying problem also applies to our retry logic.

This code probably needs to be moved to a function and called both inside and outside of the loop.

>All comments

Confirmed. From what I can see, the underlying problem also applies to our retry logic.

This code probably needs to be moved to a function and called both inside and outside of the loop.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nnals picture nnals  路  4Comments

jacob-fueled picture jacob-fueled  路  3Comments

sarneeh picture sarneeh  路  6Comments

davalapar picture davalapar  路  6Comments

sindresorhus picture sindresorhus  路  7Comments