Hi,
I am creating personal blog for my project and I would like to implement searchbar for searching and displaying list of max 5 posts containing input value in its title. Is there any possibility to make such request through content-api?
I tried that kind of solution but it responds with errors:
export async function filterArticlesByTitle(title, limit) {
return await api.posts
.browse({ limit, fields: "slug,title,published_at", filter: `title:${title}` })
.catch(err => console.error(err))
}
Which errors are you receiving?
I have one post titled „Coming soon” and few „TestX”, where X is a number between 1-16, so trying to filter them with searchbox but two things happen:
- If I try to filter „TestX” posts, I get result only after typing exact title, i.e. „Test4”. I would expect to receive array of 5 posts matching input value if I type „test”.
- If I try to find post titled „Coming soon”, errors display in a console after typing space character in the input:
GET <HOST_URL>/ghost/api/v3/content/posts/?key=41317c941e1856bb8f2189b327&limit=5&fields=slug%2Ctitle%2Cpublished_at&filter=title%3AComing%20soon 400
Error: Error parsing filter
at eval (content-api.js?1204:4520)