-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
45 lines (34 loc) · 808 Bytes
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import axios from "axios"
import * as dotenv from 'dotenv'
dotenv.config()
console.log( process.env.API_TOKEN )
export const API_KEY = {
SOLITARY_DEATH: {
NAVER: 'FiB8UwCK',
},
ARREST: {
NAVER: '7DbuwYms'
},
LOST_PEOPLE: {
GOV: 'CJJW0Avt'
}
}
const BASE_URL = `https://www.listly.io/api/single`
const API_URL = key => `${BASE_URL}?key=${key}&selected=1&arrange=y&href=y&file=json`
const headers = {
headers: {'Authorization': process.env.API_TOKEN}
}
export const Listly = () =>
{
const fetch = async ( key ) =>
{
const data = await axios.get( API_URL( key ), headers )
return data
}
return {fetch}
}
export const fetchKeyword = async ( key ) =>
{
const {data} = await Listly().fetch( key )
return data
}