forked from loafle/openapi-generator-original
* add check on response * improve check on response * update sample * fix spaces
This commit is contained in:
parent
73c55c11dd
commit
4ac2738f0a
@ -372,7 +372,7 @@ class ApiClient {
|
|||||||
* @param {Array.<String>} accepts An array of acceptable response MIME types.
|
* @param {Array.<String>} accepts An array of acceptable response MIME types.
|
||||||
* @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
|
* @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
|
||||||
* constructor for a complex type.
|
* constructor for a complex type.
|
||||||
* @param {String} apiBasePath base path defined in the operation/path level to override the default one
|
* @param {String} apiBasePath base path defined in the operation/path level to override the default one
|
||||||
{{^usePromises}}
|
{{^usePromises}}
|
||||||
* @param {module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient~callApiCallback} callback The callback function.
|
* @param {module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient~callApiCallback} callback The callback function.
|
||||||
{{/usePromises}}
|
{{/usePromises}}
|
||||||
@ -469,10 +469,12 @@ class ApiClient {
|
|||||||
request.end((error, response) => {
|
request.end((error, response) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
var err = {};
|
var err = {};
|
||||||
err.status = response.status;
|
if (response) {
|
||||||
err.statusText = response.statusText;
|
err.status = response.status;
|
||||||
err.body = response.body;
|
err.statusText = response.statusText;
|
||||||
err.response = response;
|
err.body = response.body;
|
||||||
|
err.response = response;
|
||||||
|
}
|
||||||
err.error = error;
|
err.error = error;
|
||||||
|
|
||||||
reject(err);
|
reject(err);
|
||||||
|
@ -355,7 +355,7 @@ class ApiClient {
|
|||||||
* @param {Array.<String>} accepts An array of acceptable response MIME types.
|
* @param {Array.<String>} accepts An array of acceptable response MIME types.
|
||||||
* @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
|
* @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
|
||||||
* constructor for a complex type.
|
* constructor for a complex type.
|
||||||
* @param {String} apiBasePath base path defined in the operation/path level to override the default one
|
* @param {String} apiBasePath base path defined in the operation/path level to override the default one
|
||||||
* @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
|
* @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
|
||||||
*/
|
*/
|
||||||
callApi(path, httpMethod, pathParams,
|
callApi(path, httpMethod, pathParams,
|
||||||
@ -447,10 +447,12 @@ class ApiClient {
|
|||||||
request.end((error, response) => {
|
request.end((error, response) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
var err = {};
|
var err = {};
|
||||||
err.status = response.status;
|
if (response) {
|
||||||
err.statusText = response.statusText;
|
err.status = response.status;
|
||||||
err.body = response.body;
|
err.statusText = response.statusText;
|
||||||
err.response = response;
|
err.body = response.body;
|
||||||
|
err.response = response;
|
||||||
|
}
|
||||||
err.error = error;
|
err.error = error;
|
||||||
|
|
||||||
reject(err);
|
reject(err);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user