diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-04-28 10:51:17 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-04-28 10:51:17 +0700 |
| commit | 22afd4cf502a4dbd7bf68308cd92443545336645 (patch) | |
| tree | 3287ec808d0610029d36c2e02c450b4dd5a7cafa /src/pages | |
| parent | 8b42783cd838b1da78d3d192860861ada5d13514 (diff) | |
search spell when not found
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/api/shop/spell.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/pages/api/shop/spell.js b/src/pages/api/shop/spell.js new file mode 100644 index 00000000..634adb50 --- /dev/null +++ b/src/pages/api/shop/spell.js @@ -0,0 +1,19 @@ +import axios from 'axios' + +export default async function handler(req, res) { + const { q = '' } = req.query + + let result = await axios( + process.env.SOLR_HOST + + `/solr/product/spell?indent=true&q.op=AND&q=${q}` + ) + + try { + res.status(200).json(result.data) + } catch (error) { + res.status(400).json({ + numFound: 0, + suggestions: [] + }) + } +} |
