Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
zango-strapi
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 f2c8df1d
authored
2024-05-27 17:50:20 +0530
by
jaymehta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
search bar custom api
1 parent
cb90f3ef
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
src/api/experience/controllers/experience.js
src/api/experience/routes/custom-routes.js
src/api/experience/controllers/experience.js
View file @
f2c8df1
...
...
@@ -274,4 +274,45 @@ module.exports = createCoreController("api::experience.experience", () => ({
ctx
.
throw
(
500
,
error
);
}
},
async
getSearchResponse
(
ctx
)
{
const
string
=
ctx
.
request
.
body
.
string
;
console
.
log
(
"str"
,
ctx
.
request
.
body
.
string
);
if
(
!
string
.
length
>
0
)
{
return
ctx
.
notFound
(
"Please pass a valid string"
);
}
const
activities
=
await
strapi
.
db
.
query
(
"api::experience.experience"
)
.
findMany
({
where
:
{
name
:
{
$contains
:
string
,
},
},
});
const
categories
=
await
strapi
.
db
.
query
(
"api::categorie.categorie"
)
.
findMany
({
where
:
{
name
:
{
$contains
:
string
,
},
},
});
console
.
log
(
"activities"
,
activities
);
console
.
log
(
"categories"
,
categories
);
let
responseData
=
{};
responseData
[
"categories"
]
=
categories
?.
map
((
item
)
=>
{
return
{
id
:
item
.
id
,
name
:
item
.
name
};
});
responseData
[
"activities"
]
=
activities
?.
map
((
item
)
=>
{
return
{
id
:
item
.
id
,
name
:
item
.
name
};
});
return
ctx
.
send
({
success
:
true
,
data
:
responseData
,
});
},
}));
src/api/experience/routes/custom-routes.js
View file @
f2c8df1
...
...
@@ -7,6 +7,14 @@ const routes = {
config
:
{
//some Configuration
},
},
{
method
:
"POST"
,
path
:
"/experience/get-search-response"
,
handler
:
"api::experience.experience.getSearchResponse"
,
config
:
{
//some Configuration
},
}
],
};
...
...
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