File tree Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ const getResponseBody = async (response: Response): Promise<any> => {
3
3
try {
4
4
const contentType = response.headers.get('Content-Type');
5
5
if (contentType) {
6
- const isJSON = contentType.toLowerCase().startsWith('application/json');
6
+ const jsonTypes = ['application/json', 'application/problem+json']
7
+ const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
7
8
if (isJSON) {
8
9
return await response.json();
9
10
} else {
Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ const getResponseBody = async (response: Response): Promise<any> => {
3
3
try {
4
4
const contentType = response.headers.get('Content-Type');
5
5
if (contentType) {
6
- const isJSON = contentType.toLowerCase().startsWith('application/json');
6
+ const jsonTypes = ['application/json', 'application/problem+json']
7
+ const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
7
8
if (isJSON) {
8
9
return await response.json();
9
10
} else {
Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ const getResponseBody = (xhr: XMLHttpRequest): any => {
3
3
try {
4
4
const contentType = xhr.getResponseHeader('Content-Type');
5
5
if (contentType) {
6
- const isJSON = contentType.toLowerCase().startsWith('application/json');
6
+ const jsonTypes = ['application/json', 'application/problem+json']
7
+ const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
7
8
if (isJSON) {
8
9
return JSON.parse(xhr.responseText);
9
10
} else {
Original file line number Diff line number Diff line change @@ -463,7 +463,8 @@ const getResponseBody = async (response: Response): Promise<any> => {
463
463
try {
464
464
const contentType = response.headers.get('Content-Type');
465
465
if (contentType) {
466
- const isJSON = contentType.toLowerCase().startsWith('application/json');
466
+ const jsonTypes = ['application/json', 'application/problem+json']
467
+ const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
467
468
if (isJSON) {
468
469
return await response.json();
469
470
} else {
@@ -3522,7 +3523,8 @@ const getResponseBody = async (response: Response): Promise<any> => {
3522
3523
try {
3523
3524
const contentType = response.headers.get('Content-Type');
3524
3525
if (contentType) {
3525
- const isJSON = contentType.toLowerCase().startsWith('application/json');
3526
+ const jsonTypes = ['application/json', 'application/problem+json']
3527
+ const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
3526
3528
if (isJSON) {
3527
3529
return await response.json();
3528
3530
} else {
You can’t perform that action at this time.
0 commit comments