in packages/core/alfa-core/src/utils/interceptors/responseInterceptor.ts [75:98]
export default async function responseInterceptor(response: AxiosResponse<any>) {
const { data, config } = response;
const { url } = config;
// check data is legal object JSON
if (isLegal(url, data)) {
return response;
} else {
config.url = url?.replace(/:\/\/cws\.alicdn\.com\//, '://cws2.alicdn.com/');
const newResponse = await axios(config);
if (isLegal(url, newResponse.data)) {
return newResponse;
}
}
const error = new Error() as AxiosError;
error.message = 'responseDataIllegal';
error.code = '0';
error.config = config;
error.response = response;
throw error;
}