forked from GetStream/stream-react-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExplore.js
More file actions
44 lines (40 loc) · 835 Bytes
/
Copy pathExplore.js
File metadata and controls
44 lines (40 loc) · 835 Bytes
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
import * as axios from 'axios';
import config from 'config';
/**
* LOAD
* @type {string}
*/
export const LOAD = 'EXPLORE_LOAD';
/**
* _loadRequest
* @private
*/
const _loadRequest = () => ({ type: LOAD });
/**
* _loadResponse
* @param response
* @private
*/
const _loadResponse = response => ({ type: LOAD, response });
/**
* load
* Gets explore data from API for user
* Redux Action
* Reference: http://redux.js.org/docs/basics/Actions.html
* @returns {Function}
*/
export function load() {
return (dispatch, getState) => {
dispatch(_loadRequest());
const user = getState().User;
axios
.get(`${config.api.baseUrl}/explore?user_id=${user.id}`, {
headers: {
Authorization: `Bearer ${localStorage.getItem('jwt')}`,
},
})
.then(res => {
dispatch(_loadResponse(res.data));
});
};
}