UNPKG

tix-react-ssr

Version:

Tiket.com React Project Scripts

14 lines (11 loc) 300 B
export default function parseJSON(context) { return function(response) { if (!response) { throw new Error(`Non JSON string given : ${JSON.stringify(response)}`, context); } if (typeof response === 'object') { return response; } return JSON.parse(response); }; }