-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.js
39 lines (31 loc) · 793 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
//@flow
import axios from 'axios'
const BASE_URL = 'https://us-central1-vybe-6b570.cloudfunctions.net/'
const urls = {
posts: {
TRENDING: 'getTrendingPosts',
HOT: 'getHotPosts',
LATEST: 'getLatestPosts',
},
}
function getApiUrl(path) {
return `${BASE_URL}${path}`
}
function getPosts(type: string, options: Object) {
const path = getApiUrl(type)
return axios.get(path, { params: { ...options } })
}
export function getTrendingPosts(options: Object) {
return getPosts(urls.posts.TRENDING, options)
}
export function getLatestPosts(options: Object) {
return getPosts(urls.posts.LATEST, options)
}
export function getHotPosts(options: Object) {
return getPosts(urls.posts.HOT, options)
}
export default {
getTrendingPosts,
getLatestPosts,
getHotPosts,
}