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

Unable to get hook to fire #611

Closed
ruudud opened this issue Sep 13, 2018 · 3 comments
Closed

Unable to get hook to fire #611

ruudud opened this issue Sep 13, 2018 · 3 comments
Labels
bug Something does not work as it should

Comments

@ruudud
Copy link

ruudud commented Sep 13, 2018

Hi, have some trouble getting the beforeRequest hook to fire. Tested using master (292f78a).

const inst = got.extend({ hooks: { beforeRequest: [ () => { console.log('test'); } ] } });
inst.get('http://httpbin.org/'); // nothing logged

The only way I can get it to fire, is using got.create and adding a custom handler.

What am I doing wrong?

@loris
Copy link

loris commented Sep 13, 2018

I do confirm the issue against master.

It will only work this way:

inst('http://httpbin.org/');

If you use method shortcut (ie, inst.get('http://httpbin.org/');) or any options (ie, inst('http://httpbin.org/', { method: 'GET' });, hooks will not fire.

@szmarczak szmarczak added the bug Something does not work as it should label Sep 13, 2018
@szmarczak
Copy link
Collaborator

szmarczak commented Sep 13, 2018

inst('http://httpbin.org/', {});

doesn't work either.

@szmarczak
Copy link
Collaborator

Found solution, working on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as it should
Projects
None yet
Development

No branches or pull requests

3 participants