File size: 662 Bytes
0527ba9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
// 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
}
};
|