Commit 5818f636 by kashif ansari

error handling for api call

1 parent f086ee3d
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
}, },
"httpResposneBody": { "httpResposneBody": {
"type": "text" "type": "text"
},
"thirdPartyApiError": {
"type": "boolean",
"default": false
} }
} }
} }
...@@ -24,6 +24,7 @@ module.exports = createCoreController("api::lead.lead", () => ({ ...@@ -24,6 +24,7 @@ module.exports = createCoreController("api::lead.lead", () => ({
ctx.request.body.data.httpResposneBody = JSON.stringify( ctx.request.body.data.httpResposneBody = JSON.stringify(
spretoLeadData.data spretoLeadData.data
); );
ctx.request.body.data.thirdPartyApiError=false;
} catch (error) { } catch (error) {
ctx.request.body.data.httpRequestHeaders = JSON.stringify( ctx.request.body.data.httpRequestHeaders = JSON.stringify(
error.config.headers error.config.headers
...@@ -32,6 +33,7 @@ module.exports = createCoreController("api::lead.lead", () => ({ ...@@ -32,6 +33,7 @@ module.exports = createCoreController("api::lead.lead", () => ({
ctx.request.body.data.httpRequestUrl = error.config.url; ctx.request.body.data.httpRequestUrl = error.config.url;
ctx.request.body.data.httpsRequestBody = error.config.data; ctx.request.body.data.httpsRequestBody = error.config.data;
ctx.request.body.data.httpResposneBody = JSON.stringify(error.message); ctx.request.body.data.httpResposneBody = JSON.stringify(error.message);
ctx.request.body.data.thirdPartyApiError=true;
} }
const leadData = await super.create(ctx); 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!