diff --git a/lib/axios.js b/lib/axios.js index 9a4986d..93f1306 100644 --- a/lib/axios.js +++ b/lib/axios.js @@ -28,8 +28,23 @@ var axios = module.exports = function axios(config) { } }); + function deprecatedMethod(method, instead, docs) { + try { + console.warn( + 'DEPRECATED method `' + method + '`.' + + (instead ? ' Use `' + instead + '` instead.' : '') + + ' This method will be removed in a future release.'); + + if (docs) { + console.warn('For more information about usage see ' + docs); + } + } catch (e) {} + } + // Provide alias for success promise.success = function success(fn) { + deprecatedMethod('success', 'then', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api'); + promise.then(function(response) { fn(response.data, response.status, response.headers, response.config); }); @@ -38,6 +53,8 @@ var axios = module.exports = function axios(config) { // Provide alias for error promise.error = function error(fn) { + deprecatedMethod('error', 'catch', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api'); + promise.then(null, function(response) { fn(response.data, response.status, response.headers, response.config); });