FormData with jsonPlus
Kestutis opened this issue · 0 comments
Kestutis commented
Right now I can not pass FormData if I'm using jsonPlus middleware. All my responses comes as json, so I need to pass Accept header as json as well as parse response.
If I have FormData(want to upload file), I don't need Content-Type: application/json header. fetch-plus-json doesn't handle this case.
Workaround I'm using:
client.addMiddleware((request) => {
if (request.options.body instanceof FormData) {
request.options.headers["Accept"] = "application/json";
return plusJson.handler();
} else {
return plusJson()(request);
}
});