๋๊ตฌ์ํํธ์จ์ด๊ณ ๋ฑํ๊ต๋ผ๋ ํค์๋๋ก ๊ฒ์์ ํ ๋ ค๊ณ ํ ๋ ค๋ฉด,
https://dapi.kakao.com/v2/search/web?query=๋๊ตฌ์ํํธ์จ์ด๊ณ ๋ฑํ๊ต&size=10
์ด๋ฐ์์ผ๋ก ์ฟผ๋ฆฌ๋ฅผ ์์ฑํ๋ฉด ๋๋ค.
ํ์ง๋ง ์ด๋ฐ์์ผ๋ก ์์ฒญ์ ํ๊ฒ ๋๋ฉด,
{
"errorType": "AccessDeniedError",
"message": "cannot find Authorization : KakaoAK header"
}
์ด๋ฐ์์ ๋ฉ์์ง๊ฐ ๋์ค๊ฒ ๋ ํ ๋ฐ... message๋ฅผ ์ ๋ณด๋ฉด
cannot find Authorization : KakaoAK header
๋ผ๋ ๋ฉ์์ง๊ฐ ๋จ๊ฒ ๋๋ ๋ชจ์ต์ ๋ณผ ์ ์๋ค.
์ด๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํ ๋ฐฉ์์ ๊ฐ๋จํ๋ค.
๋งํฌ์์ ๋ก๊ทธ์ธ -> ๋ด ์ํ๋ฆฌ์ผ์ด์ -> ๋ฑ๋ก์ ํ์๋ฉด ์์ฝ ์ ๋ณด์ ์ฑ ํค๋ผ๋ ๊ฒ์ด ๋ฐ๊ธ์ด ๋ ๊ฒ์ด๋ค! ๊ทธ๊ณณ์์ ์์ ์ด ํ์ํ APIํค๋ฅผ ๊ฐ์ ธ๋ค ์ฐ๋ฉด ๋๋๋ฐ, ๋๋ REST APIํค๋ฅผ ๊ฐ์ ธ๋ค๊ฐ ์ธ๊ฒ์ด๋ค.
KakaoAK์ ํ์์
"API_KEY": "KakaoAK + (๋ฐ๊ธ๋ฐ์ API_KEY)"
์ ํ์์ผ๋ก ํค๋์ ์ ์ก๋ง ํด์ฃผ๋ฉด ๋๋ค. ์ฆ, ๋์ค์ axios๋ฅผ ํตํ ์๋ฒAPIํต์ ์ ์งํํ ๋,
import { API_KEY } from 'config/config.json';
...
customAxios.get(`${SERVER}${query}`, {
headers: {
Authorization: API_KEY,
},
});
์ด๋ ๊ฒ ์์ฑํด์ฃผ๋ฉด ๋๋ค.