(filePath)
| 13370 | 'Content-Type': 'application/json' |
| 13371 | }, |
| 13372 | body: JSON.stringify(payload) |
| 13373 | }); |
| 13374 | |
| 13375 | let data = null; |
| 13376 | try { |
| 13377 | data = await response.json(); |
| 13378 | } catch (error) { |
| 13379 | data = null; |
| 13380 | } |
| 13381 | |
| 13382 | if (!response.ok || (data && data.success === false)) { |
| 13383 | const errorMessage = data && (data.error || data.message) |
| 13384 | ? (data.error || data.message) |
| 13385 | : `Request failed (${response.status})`; |
| 13386 | throw new Error(errorMessage); |
| 13387 | } |
| 13388 | |
| 13389 | return data || { success: true }; |
no test coverage detected