From 22afd4cf502a4dbd7bf68308cd92443545336645 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 28 Apr 2023 10:51:17 +0700 Subject: search spell when not found --- src/pages/api/shop/spell.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/pages/api/shop/spell.js (limited to 'src/pages/api') 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: [] + }) + } +} -- cgit v1.2.3