I have attached the error message image
#Syntaxerror : Undefined is not valid json
2 messages · Page 1 of 1 (latest)
JSON.parse() method only accept the typeof objects, if we pass any other type like undefined, null, number it will fell into exception to avoid such case write a condition above to check the input type is object.
const input = [1, 2, 3] if (typeof input === 'object') { JSON.parse(input) }