Skip to content

Commit

Permalink
feat: 카테고리 선택 시에 카테고리와 함께 쿼리문 전송
Browse files Browse the repository at this point in the history
  • Loading branch information
mini-xi committed Jul 4, 2024
1 parent 76c5add commit f24bd0c
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default {
},
data() {
return {
selectedCategory: { description: '선택' },
selectedCategory: { description: '선택', secondCategory: '', lastCategory: '', representativeName: '' },
sortOrder: 'accuracy', // 초기 정렬 순서
allProducts: [],
searchQuery: '' // 검색어를 저장하는 데이터
Expand All @@ -51,14 +51,27 @@ export default {
methods: {
async fetchProducts() {
try {
const response = await axios.get('http://api.market-nawa.store/search', {
params: {
keyword: this.searchQuery,
detailCategory: this.selectedCategory.description !== '선택' ? this.selectedCategory.description : '',
order: this.sortOrder,
size: 1000 // 최대 1000개의 결과를 가져오도록 설정
}
});
const params = {
keyword: this.searchQuery,
detailCategory: this.selectedCategory.description !== '선택' ? this.selectedCategory.description : '',
order: this.sortOrder,
size: 1000 // 최대 1000개의 결과를 가져오도록 설정
};
if (this.selectedCategory.secondCategory) {
params.secondCategory = this.selectedCategory.secondCategory;
}
if (this.selectedCategory.lastCategory) {
params.lastCategory = this.selectedCategory.lastCategory;
}
if (this.selectedCategory.representativeName) {
params.representativeName = this.selectedCategory.representativeName;
}
const response = await axios.get('http://api.market-nawa.store/search', { params });
if (response.data && response.data.data) {
this.allProducts = Object.values(response.data.data).flat(); // Assuming the data structure is a dictionary with brand-wise lists
console.log('All Products:', this.allProducts); // 가져온 모든 제품 로그
Expand Down

0 comments on commit f24bd0c

Please sign in to comment.