Commit 5818f636 by kashif ansari

error handling for api call

1 parent f086ee3d
......@@ -43,6 +43,10 @@
},
"httpResposneBody": {
"type": "text"
},
"thirdPartyApiError": {
"type": "boolean",
"default": false
}
}
}
......@@ -24,6 +24,7 @@ module.exports = createCoreController("api::lead.lead", () => ({
ctx.request.body.data.httpResposneBody = JSON.stringify(
spretoLeadData.data
);
ctx.request.body.data.thirdPartyApiError=false;
} catch (error) {
ctx.request.body.data.httpRequestHeaders = JSON.stringify(
error.config.headers
......@@ -32,6 +33,7 @@ module.exports = createCoreController("api::lead.lead", () => ({
ctx.request.body.data.httpRequestUrl = error.config.url;
ctx.request.body.data.httpsRequestBody = error.config.data;
ctx.request.body.data.httpResposneBody = JSON.stringify(error.message);
ctx.request.body.data.thirdPartyApiError=true;
}
const leadData = await super.create(ctx);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!