Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import axios from 'axios';
- import { FETCH_USER_INFO, FETCH_USER_IMG, FETCH_ALL_USERS } from './types';
- export const fetchUserInfo = (userId) => {
- async (dispatch) => {
- const response = await axios({
- method: 'get',
- url: 'http://localhost:9000/api/v1/users/info',
- headers: {"id": userId}
- });
- return dispatch({
- type: FETCH_USER_INFO,
- payload: response.data })
- };
- }
- export function fetchUserImg(userId) {
- async (dispatch) => {
- const response = await axios({
- method: 'get',
- url: 'http://localhost:9000/api/v1/users/info',
- headers: {"id": userId}
- });
- return dispatch({
- type: FETCH_USER_IMG,
- payload: response.data.photo })
- };
- }
- export const fetchAllUsers = () => async dispatch => {
- const request = await axios('http://localhost:9000/api/v1/users');
- dispatch({ type: FETCH_ALL_USERS, payload: request });
- }
Add Comment
Please, Sign In to add comment