Adds safeParseJSON.ts file
This commit is contained in:
1 parent
da88beb1f5
commit
12f54773f9
1 file changed
+8
@@ -0,0 +1,8 @@
|
||||
export default function parseJSONSafely(str: string) {
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
} catch (e) {
|
||||
console.error((e as Error).message);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user