import {
  FETCHING_PERSON_LIST,
  ERROR_FETCHING,
  SUCCESS_FETCHING,
} from '../constants/ActionTypes'
import { createAction } from 'redux-actions'
import Api from '../constants/Api'
import trae from 'trae'

export const fetchingPersonList = createAction(FETCHING_PERSON_LIST)
export const errorFetching = createAction(ERROR_FETCHING)
export const successFetching = createAction(SUCCESS_FETCHING)

export function fetchPersonList() {
  return function(dispatch) {
    dispatch(fetchingPersonList())
    const url = `${Api.baseUrl}${Api.personEndpoint}`
    trae.get(url)
      .then((response) => {
        dispatch(successFetching(response))
      })
      .catch((err) => {
        dispatch(errorFetching(err.message))
      })
  }
}

@@ -181,32 +181,8 @@
 Api'
-%0Aimport trae from 'trae'
 %0A%0Aex
@@ -439,43 +439,8 @@
 ) %7B%0A
-    dispatch(fetchingPersonList())%0A
     
@@ -497,44 +497,93 @@
     
-trae.get(url)%0A      .then((response)
+dispatch(fetchingPersonList())%0A    fetch(url)%0A      .then(res =%3E res.json().then(json
  =%3E 
@@ -621,16 +621,12 @@
 ing(
-response
+json
 ))%0A 
@@ -632,16 +632,17 @@
       %7D)
+)
 %0A      .
@@ -651,13 +651,11 @@
 tch(
-(
 err
-)
  =%3E 

use fetch