diff --git a/src/index.js b/src/index.js index d68e686..cde8c28 100644 --- a/src/index.js +++ b/src/index.js @@ -84,17 +84,17 @@ function convertDataAndConfigToConfig (method, data, config) { if (methodsWithConfigsAsSecondArg.includes(method)) { return validateconfig(method, data || {}); } else { - return validateconfig(method, Object.assign({}, config || {}, { data: data })); + return validateconfig(method, Object.assign({}, config, { data: data })); } } -var allowedConfigs = ['headers', 'params', 'data']; +var allowedConfigProperties = ['headers', 'params', 'data']; function validateconfig (method, config) { for (var key in config) { - if (!allowedConfigs.includes(key)) { + if (!allowedConfigProperties.includes(key)) { throw new Error( - 'Invalid config attribute ' + - key + + 'Invalid config property ' + + JSON.stringify(key) + ' provided to ' + toMethodName(method) + '. Config: ' + diff --git a/src/utils.js b/src/utils.js index 59916ef..ba06240 100644 --- a/src/utils.js +++ b/src/utils.js @@ -166,7 +166,12 @@ function createAxiosError(message, config, response, code) { function createCouldNotFindMockError(config) { var message = "Could not find mock for: \n" + - JSON.stringify(config, ["method", "url"], 2); + JSON.stringify({ + method: config.method, + url: config.url, + params: config.params, + headers: config.headers + }, null, 2); var error = new Error(message); error.isCouldNotFindMockError = true; error.url = config.url;