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

support non-json request bodies #18

Open
bobzoller opened this issue Jun 29, 2017 · 1 comment
Open

support non-json request bodies #18

bobzoller opened this issue Jun 29, 2017 · 1 comment

Comments

@bobzoller
Copy link
Contributor

I'd like to use this with the bill.com API, but their API accepts form-encoded request bodies and returns json responses. This bit of code prevents me from providing the body as a form-encoded string:

if (jsonFetchOptions.body !== undefined) {
parsedOptions.body = JSON.stringify(jsonFetchOptions.body);
parsedOptions.headers['Content-Type'] = 'application/json';
}

@bobzoller
Copy link
Contributor Author

seems like there's three options:
a. json-fetch doesn't care about your half-json API; use a different library
b. only JSON.stringify if body is an object (breaking change, but I would argue a standard pattern in other request libraries)
c. add rawBody or some other parameter

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

1 participant