Skip to content

Ordering of Middleware #6

@drewmoore

Description

@drewmoore

I was curious about the order in which middleware is being applied by fetch-wrap. This is an awesome library that we use heavily for our projects. We ran into a curious case where it seems that custom middleware would need to be applied in reverse-order, bottom-to-top, instead of top-to-bottom. For example:

const newFetch = fetchWrap(originalFetch, [
  doFirstThing(),
  doSecondThing(),
  doThirdThing()
]);

This would first call doThirdThing, then proceed backwards. Is this the intended behavior? I would hesitate to call it a "bug", since I see the test expectations in the repository that mimic these results. I have forked the repo and created a new test to better illustrate what I mean:

https://github.com/drewmoore/fetch-wrap/blob/1dfd6648d426d16a3981a18d058422118053dddc/test/middleware.js#L353

If this is something that you and the community would like to have adjusted, I would be happy to take a stab at it and submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions