All files / actions resultActions.js

70% Statements 7/10
100% Branches 0/0
50% Functions 3/6
66.67% Lines 4/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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        4x         4x                         4x       4x        
// @flow
import axios from 'axios';
import { SAVE_GIFS, CLEAR_GIFS, SET_CHOSEN } from './types';
 
export const saveGifs = (arr: Array<string>): Object => ({
  type: SAVE_GIFS,
  payload: arr,
});
 
export const getGifs = () => (dispatch: Function, getState: Function) => {
  axios
    .get(
      `https://api.tenor.com/v1/search?q=${getState().form.input}&key=${
        getState().settings.apikey
      }`
    )
    .then(response => {
      dispatch(saveGifs(response.data.results));
    })
    .catch();
};
 
export const clearGifs = () => ({
  type: CLEAR_GIFS,
});
 
export const setChosen = (url: string) => ({
  type: SET_CHOSEN,
  payload: url,
});