正在执行一项需要在 Algolia Search 上进行搜索的任务
这对于所有字母文本都工作正常,但对于像 é 这样的特殊字符会出现错误
const index = client.initIndex(indexName);
return index
.search("", {
params: "filters=section_name:Design + Décor",
})
.then(({ hits }: any) => {
console.log(hits)
});
我收到以下错误
"filters: Unexpected token string(Décor) expected end of filter"
任何对此的指导表示赞赏
提前致谢
您可以使用 URL 编码对特殊字符进行编码
encodeURIComponent
const index = client.initIndex(indexName);
const sectionName = encodeURIComponent("Design + Décor");
return index
.search("", {
params: `filters=section_name:${sectionName}`,
})
.then(({ hits }) => {
console.log(hits)
});