안형욱

refact: es search 결과 형식 변경

1 import axios from 'axios'; 1 import axios from 'axios';
2 2
3 const esInstance = axios.create({ 3 const esInstance = axios.create({
4 - baseURL: process.env.API_ENDPOINT, 4 + baseURL: process.env.REACT_APP_API_ENDPOINT,
5 headers: { 5 headers: {
6 'Content-Type': 'application/json', 6 'Content-Type': 'application/json',
7 - Authorization: `Bearer ${process.env.SEARCH_KEY}`, 7 + Authorization: `Bearer ${process.env.REACT_APP_SEARCH_KEY}`,
8 }, 8 },
9 }); 9 });
10 10
11 -export const search = async searchWord => { 11 +export const esApi = {
12 - const res = await esInstance.post( 12 + search: async searchWord => {
13 - `/api/as/v1/engines/${process.env.APP_SEARCH_ENGINE_NAME}/search`, 13 + const res = await esInstance.post(
14 - { 14 + `/api/as/v1/engines/${process.env.REACT_APP_ENGINE_NAME}/search`,
15 - query: searchWord, 15 + {
16 - } 16 + query: searchWord,
17 - ); 17 + }
18 + );
18 19
19 - console.log(res); 20 + return res.data;
20 - return res; 21 + },
21 }; 22 };
......