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

Suggestion: Allow partial response mocking #40

Open
JoshWhite opened this issue Jan 31, 2020 · 3 comments
Open

Suggestion: Allow partial response mocking #40

JoshWhite opened this issue Jan 31, 2020 · 3 comments

Comments

@JoshWhite
Copy link

I've just had a go at chucking this into a mature app, with an existing API.
I only need to make a small change; eg. add a couple of properties, to an existing call.

But I want the rest of the api response to remain the same.

It would be great if you could trap a response from the server & manipulate it before handing back to the calling code.

@samselikoff samselikoff transferred this issue from miragejs/miragejs Jan 31, 2020
@samselikoff
Copy link
Contributor

Interesting idea!

Mirage route handlers are promise-aware so you could try fetching from your Mirage code, massaging and the responding. (Then it wouldn't work offline/locally.)

I've also seen folks copy+paste an existing response into their repo and using the passthrough api to let all other responses hit the existing API.

@JoshWhite
Copy link
Author

Yeah, I’m using the passthrough api 👍.

Ah ok, you mean hijack the request header in a route function, hand the call onto the api, then modify its response before returning?

Sounds like you can already do this then 😀

@samselikoff
Copy link
Contributor

samselikoff commented Feb 1, 2020

Yes, but re-calling the api might involve a bit of boilerplate. Basically there’s nothing first class in Mirage to support this but because route handlers wait on promises you might be able to do it today!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants