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

Feature request: support non-JSON requests/responses #16

Closed
zmwangx opened this issue Apr 3, 2021 · 1 comment · Fixed by #17
Closed

Feature request: support non-JSON requests/responses #16

zmwangx opened this issue Apr 3, 2021 · 1 comment · Fixed by #17

Comments

@zmwangx
Copy link
Contributor

zmwangx commented Apr 3, 2021

I'm trying to mock a third-party API that returns base64-encoded binary data as text/plain. Unfortunately, at the moment parseJson, application/plain and JSON.stringify are hard-coded so that seems impossible.

https://github.com/anncwb/vite-plugin-mock/blob/798c61ddd81b9af782ca870139b4a2a6938d624a/src/createMockServer.ts#L77-L83

Would you consider adding support for arbitrary requests and responses? I have a patch at zmwangx@48e9564 adding a rawResponse option to MockMethod to achieve this. I can send a PR if you're okay with that approach, but as long as this use case is made possible, anything goes for me. Thanks.

@anncwb
Copy link
Collaborator

anncwb commented Apr 3, 2021

This is ok, pr is welcome

zmwangx added a commit to zmwangx/vite-plugin-mock that referenced this issue Apr 3, 2021
With rawResponse we can parse arbitrary requests and return arbitrary
responses, instead of being limited to application/json.

Fixes vbenjs#16.
@anncwb anncwb closed this as completed in #17 Apr 6, 2021
anncwb pushed a commit that referenced this issue Apr 6, 2021
With rawResponse we can parse arbitrary requests and return arbitrary
responses, instead of being limited to application/json.

Fixes #16.
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

Successfully merging a pull request may close this issue.

2 participants