mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
Testing and cleanup of transformResponse (#3377)
- Tests for transformResponse - Remove eslint error by renaming the var - Test that there data a length to avoid JSON.parse headache - Use `util.isString()` over `typeof` Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
+4
-4
@@ -55,13 +55,13 @@ var defaults = {
|
||||
}],
|
||||
|
||||
transformResponse: [function transformResponse(data) {
|
||||
/*eslint no-param-reassign:0*/
|
||||
if (typeof data === 'string') {
|
||||
var result = data;
|
||||
if (utils.isString(result) && result.length) {
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
result = JSON.parse(result);
|
||||
} catch (e) { /* Ignore */ }
|
||||
}
|
||||
return data;
|
||||
return result;
|
||||
}],
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user