JSON.parse fails if response is not JSON. Added try/catch to make it safer