mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-10 13:50:05 +00:00
chore: preventing double parse of invalid json check
This commit is contained in:
@@ -4,8 +4,9 @@
|
|||||||
*/
|
*/
|
||||||
export const isValidJson = (str: string | object) => {
|
export const isValidJson = (str: string | object) => {
|
||||||
try {
|
try {
|
||||||
str = typeof str !== 'string' ? JSON.stringify(str) : str
|
if (typeof str === 'object') return
|
||||||
JSON.parse(str)
|
|
||||||
|
str = JSON.parse(str)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('Invalid JSON response.')
|
throw new Error('Invalid JSON response.')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user