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 1a8a62c1
authored
2023-02-03 12:25:56 +0530
by
jay
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
utm
1 parent
ef7597d3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
src/api/lead/controllers/lead.js
src/api/lead/services/lead.js
src/api/lead/controllers/lead.js
View file @
1a8a62c
...
...
@@ -10,11 +10,13 @@ module.exports = createCoreController("api::lead.lead", () => ({
async
sendLeads
(
ctx
)
{},
async
create
(
ctx
)
{
console
.
log
(
">>>>"
,
ctx
);
try
{
const
spretoLeadData
=
await
strapi
.
service
(
"api::lead.lead"
)
.
sendLeadToSperto
(
ctx
.
request
.
body
.
data
);
console
.
log
(
"spretoLeadData"
,
spretoLeadData
);
ctx
.
request
.
body
.
data
.
httpRequestHeaders
=
JSON
.
stringify
(
spretoLeadData
.
headers
);
...
...
@@ -24,7 +26,7 @@ module.exports = createCoreController("api::lead.lead", () => ({
ctx
.
request
.
body
.
data
.
httpResposneBody
=
JSON
.
stringify
(
spretoLeadData
.
data
);
ctx
.
request
.
body
.
data
.
thirdPartyApiError
=
false
;
ctx
.
request
.
body
.
data
.
thirdPartyApiError
=
false
;
}
catch
(
error
)
{
ctx
.
request
.
body
.
data
.
httpRequestHeaders
=
JSON
.
stringify
(
error
.
config
.
headers
...
...
@@ -33,7 +35,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
;
ctx
.
request
.
body
.
data
.
thirdPartyApiError
=
true
;
}
const
leadData
=
await
super
.
create
(
ctx
);
...
...
src/api/lead/services/lead.js
View file @
1a8a62c
...
...
@@ -21,6 +21,9 @@ module.exports = createCoreService("api::lead.lead", ({ strapi: Strapi }) => ({
mobile_no1
:
data
.
mobileNumber
,
email_id1
:
data
.
email
,
otp_verified_yn
:
"N"
,
page_url
:
data
.
UTMLink
?
data
.
UTMLink
:
""
,
utm_medium
:
data
.
utm_medium
?
data
.
utm_medium
:
""
,
utm_source
:
data
.
utm_source
?
data
.
utm_source
:
""
};
if
(
data
.
comments
)
{
leadData
.
comments
=
data
.
comments
;
...
...
@@ -35,13 +38,21 @@ module.exports = createCoreService("api::lead.lead", ({ strapi: Strapi }) => ({
});
leadData
.
project_name
=
projectData
.
projectName
;
}
// if (data.UTMLink) {
// leadData = {...leadData, page_url: data.UTMLink}
// }
// if (data.utm_medium) {
// leadData = {...leadData, utm_medium: data.utm_medium}
// }
// if (data.utm_source) {
// leadData = {...leadData, utm_source: data.utm_source}
// }
const
spertoResponse
=
await
axios
.
post
(
"https://net4hgc.sperto.co.in/_api/api_auth_post_lead_json.php"
,
leadData
,
{
headers
:
headers
}
);
console
.
log
(
"spertoResponse"
,
spertoResponse
);
return
spertoResponse
;
},
}));
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