Skip to content

Commit

Permalink
feat: 네이버 api 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Leeseunghwan7305 committed Apr 20, 2024
1 parent f4188b1 commit efd403e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/api/costComparison/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export async function GET({ nextUrl }: NextRequest) {
const query = searchParams.get('searchData');
try {
const response = await axios.get(
`https://openapi.naver.com/v1/search/shop.json?query=${query}
`https://openapi.naver.com/v1/search/shop.json?query=${query}&display=30
`,
{
headers: {
Expand Down
14 changes: 13 additions & 1 deletion src/hooks/useInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { debounce } from 'lodash';
import React, { useState } from 'react';

type ReturnType = [
Expand All @@ -11,8 +12,13 @@ type ReturnType = [
const useInput = (): ReturnType => {
const [value, setValue] = useState('');

const debouncedSetValue = debounce((inputValue) => {
setValue(inputValue);
}, 500);

const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setValue(e.target.value);
const inputValue = e.target.value;
debouncedSetValue(inputValue);
};
const reset = () => {
setValue('');
Expand All @@ -22,3 +28,9 @@ const useInput = (): ReturnType => {
};

export default useInput;

/**
* const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setValue(e.target.value);
};
*/

0 comments on commit efd403e

Please sign in to comment.