Added error catching to JSON.parse(payload)