Handle empty response.body from superagent

Superagent does not always produce a `body`. See
http://visionmedia.github.io/superagent/ for details. When it
doesn't, we should deserialize the raw `response.text` rather
than returning `null`. Currently, the JS client always returns
`null` when the return type is String! This commit fixes
that.
This commit is contained in:
delenius
2016-02-17 09:30:20 -08:00
parent 61215f31fb
commit 692c865c76
7 changed files with 104 additions and 27 deletions

View File

@@ -211,7 +211,9 @@
// See http://visionmedia.github.io/superagent/#parsing-response-bodies
var data = response.body;
if (data == null) {
return null;
// Superagent does not always produce a body; use the unparsed response
// as a fallback
data = response.text;
}
return ApiClient.convertToType(data, returnType);
};