nexora / frontend /src /api /searchApi.js
ChandimaPrabath's picture
update
0527ba9
raw
history blame
662 Bytes
// lib/searchApi.js or utils/searchApi.js based on your structure
import axios from 'axios';
import config from '@/lib/config'; // Adjust path if necessary
const searchUrl = config.searchUrl;
/**
* Perform a search query.
* @param {string} query - The search query.
* @returns {Promise<Object>} - The search results.
*/
export const search = async (query) => {
try {
const response = await axios.post(searchUrl, { query });
console.log(response);
return response.data;
} catch (error) {
console.error("Error performing search:", error);
throw error; // Rethrow the error to be handled by the caller
}
};