Adds safeParseJSON.ts file
parent
da88beb1f5
commit
12f54773f9
|
@ -0,0 +1,8 @@
|
|||
export default function parseJSONSafely(str: string) {
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
} catch (e) {
|
||||
console.error((e as Error).message);
|
||||
return {};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue