forked from loafle/openapi-generator-original
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:
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user