Added a comment for posterity
This commit is contained in:
parent
4dc2f2f267
commit
de49f096b1
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user