Skip to content

Commit 38a8bca

Browse files
committed
fix(modules): Better debuging modules request errors on checkout flow
1 parent 615237e commit 38a8bca

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

packages/modules/src/firebase/functions-checkout/request-to-module.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,30 @@ export default async (
4242
is_checkout_confirmation: true,
4343
};
4444
try {
45-
const resp = (await axios.post(
46-
url,
47-
body,
48-
)).data;
45+
const { data: { result } } = await axios.post(url, body);
4946
// find application validation error
50-
if (Array.isArray(resp.result)) {
47+
if (Array.isArray(result)) {
5148
let countAppErro = 0;
52-
for (let i = 0; i < resp.result.length; i++) {
53-
const result = resp.result[i];
54-
if (!result.validated || result.error) {
49+
for (let i = 0; i < result.length; i++) {
50+
const { validated, error, response } = result[i];
51+
if (!validated || error) {
5552
countAppErro += 1;
56-
logger.error(result.response);
57-
msgErr.moreInfo += ` ${result.response}`;
53+
logger.error(response);
54+
msgErr.moreInfo += ` ${response}`;
5855
}
5956
}
60-
if (resp.result.length === countAppErro) {
57+
if (result.length === countAppErro) {
6158
msgErr.code = 'APP_MODULE_ERROR_VALIDATION';
6259
return { msgErr };
6360
}
6461
}
65-
return resp.result;
62+
return result;
6663
} catch (err: any) {
6764
logger.error(err);
65+
logger.warn(`Error on post to ${url}`, {
66+
body,
67+
response: err.response?.data,
68+
});
6869
msgErr.moreInfo = 'Unexpected error ';
6970
if (axios.isAxiosError(err)) {
7071
msgErr.moreInfo = err.message;

0 commit comments

Comments
 (0)