Skip to content

Commit

Permalink
Provide json to HttpResponse.json()
Browse files Browse the repository at this point in the history
  • Loading branch information
IanVS committed Jun 12, 2024
1 parent 4f70d7d commit cdf9043
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/msw-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export default class MswConfig {
// Return the correct type of response based on the `accept` header
const accept = request.headers?.get('accept')?.toLowerCase() || '';
if (accept.includes('json')) {
return HttpResponse.json(responseBody, init);
return HttpResponse.json(JSON.parse(responseBody || '{}'), init);
} else if (accept.includes('text')) {
return HttpResponse.text(responseBody, init);
} else {
Expand Down

0 comments on commit cdf9043

Please sign in to comment.