Added a comment for posterity

This commit is contained in:
Chris Raible 2024-08-30 00:18:32 -07:00
parent 4dc2f2f267
commit de49f096b1

View File

@ -188,8 +188,10 @@ export async function mockApi<Requests extends Record<string, MockRequestConfig>
let requestBody = null; let requestBody = null;
try { try {
// Try to parse the post data as JSON
requestBody = JSON.parse(route.request().postData() || 'null'); requestBody = JSON.parse(route.request().postData() || 'null');
} catch { } catch {
// Post data isn't JSON (e.g. file upload) — use the raw post data
requestBody = route.request().postData(); requestBody = route.request().postData();
} }