Skip to content

Commit 2158510

Browse files
committed
Fix empty response error for some samples
1 parent e1e09e4 commit 2158510

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Static/lib/azure-maps/azure-maps-helper.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ async function processPostRequest(url, body) {
3333
throw new Error(`Network response was not ok: ${response.status} ${response.statusText}`);
3434
}
3535

36+
// If the response body is empty, return the response directly to avoid JSON parsing errors.
37+
// This can happen if the request was successful but there is no content to return.
38+
// e.g., 204 No Content or 202 Accepted
39+
if (response.status === 204 || response.status === 202) {
40+
return response;
41+
}
42+
3643
return response.json();
3744
}
3845

Static/lib/azure-maps/azure-maps-helper.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)