Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
strapi-setup-file
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 5818f636
authored
2022-11-03 17:58:39 +0530
by
kashif ansari
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
error handling for api call
1 parent
f086ee3d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
src/api/lead/content-types/lead/schema.json
src/api/lead/controllers/lead.js
src/api/lead/content-types/lead/schema.json
View file @
5818f63
...
...
@@ -43,6 +43,10 @@
},
"httpResposneBody"
:
{
"type"
:
"text"
},
"thirdPartyApiError"
:
{
"type"
:
"boolean"
,
"default"
:
false
}
}
}
src/api/lead/controllers/lead.js
View file @
5818f63
...
...
@@ -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
);
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment