mirror of
https://github.com/tenrok/axios.git
synced 2026-06-05 16:42:32 +03:00
feat: support reviver on JSON.parse (#5926)
* test: test to support reviver on JSON.parse * feat: support reviver for JSON.parse on parse response data #5924 --------- Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -2332,4 +2332,22 @@ describe('supports http with nodejs', function () {
|
||||
}, /ENOTFOUND/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('JSON', function() {
|
||||
it('should support reviver on JSON.parse', async function () {
|
||||
server = await startHTTPServer(async (_, res) => {
|
||||
res.end(JSON.stringify({
|
||||
foo: 'bar'
|
||||
}));
|
||||
});
|
||||
|
||||
const {data} = await axios.get(LOCAL_SERVER_URL, {
|
||||
parseReviver: (key, value) => {
|
||||
return key === 'foo' ? 'success' : value;
|
||||
},
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(data, {foo: 'success'});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user