blob: 2db93ce47afe019ea5cbe1ae4bf9a1ee289d103c (
plain)
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
|
import axios from 'axios';
import {
FETCH_TRENDING_FAILED,
FETCH_TRENDING_SUCCESS,
PROCESS_FETCH_TRENDING
} from './types';
const API_URL = 'https://api.github.com/search/repositories';
/**
* @param {object} filters
* @returns {Function}
*/
export const fetchTrending = function (filters) {
return dispatch => {
dispatch({ type: PROCESS_FETCH_TRENDING });
axios.get(API_URL, {
params: filters
}).then(response => {
dispatch({
type: FETCH_TRENDING_SUCCESS,
payload: response.data
});
}).catch(error => {
dispatch({
type: FETCH_TRENDING_FAILED,
payload: error
});
});
};
};
|