Open
Description
I need to add a condition. Let me explain first
export const getResponseBody = async (response: Response): Promise<any> => {
if (response.status !== 204) {
try {
const contentType = response.headers.get('Content-Type');
if (contentType) {
const jsonTypes = ['application/json', 'application/problem+json'];
const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
if (isJSON) {
return await response.json();
} else if (contentType === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") {
return await response.arrayBuffer();
} else {
return await response.text();
}
}
} catch (error) {
console.error(error);
}
}
return undefined;
};
I found that const contentType = response.headers.get('Content-Type'); in my code sends "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet". I want to modify it to have the condition:
if (contentType === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") {
return await response.arrayBuffer();
}
Because I need arrayBuffer(), and I've tested and found that json() or text() are insufficient conditions to support response handling adequately. Please grant me permission to make these changes in the file path core/request.ts."
If you need further adjustments or have more details to add, feel free to let me know!
export const getResponseBody = async (response: Response): Promise<any> => {
if (response.status !== 204) {
try {
const contentType = response.headers.get('Content-Type');
if (contentType) {
if (contentType === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"){
return await response.arrayBuffer()
}
const jsonTypes = ['application/json', 'application/problem+json']
const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
if (isJSON) {
return await response.json();
} else {
return await response.text();
}
}
} catch (error) {
console.error(error);
}
}
return undefined;
};
Metadata
Metadata
Assignees
Labels
No labels