-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fc292f
commit 8414e35
Showing
5 changed files
with
46 additions
and
57 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const styles = { | ||
text: { | ||
color: 'rebeccapurple', | ||
}, | ||
}; | ||
|
||
export default styles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,28 @@ | ||
import { Dispatch } from 'redux'; | ||
import { DictionaryActionTypes, IWord } from '../types'; | ||
|
||
export function fetchDictionaryStart() { | ||
return { | ||
type: DictionaryActionTypes.FETCH_START, | ||
}; | ||
} | ||
export const fetchDictionaryStart = () => ({ | ||
type: DictionaryActionTypes.FETCH_START, | ||
}); | ||
|
||
export function fetchDictionarySuccess(words: IWord[]) { | ||
return { | ||
type: DictionaryActionTypes.FETCH_SUCCESS, | ||
payload: { words }, | ||
}; | ||
} | ||
export const fetchDictionarySuccess = (words: IWord[]) => ({ | ||
type: DictionaryActionTypes.FETCH_SUCCESS, | ||
payload: { words }, | ||
}); | ||
|
||
export function fetchDictionaryError(error: Error) { | ||
return { | ||
type: DictionaryActionTypes.FETCH_ERROR, | ||
payload: { error }, | ||
}; | ||
} | ||
export const fetchDictionaryError = (error: Error) => ({ | ||
type: DictionaryActionTypes.FETCH_ERROR, | ||
payload: { error }, | ||
}); | ||
|
||
export function fetchDictionary() { | ||
return async (dispatch: Dispatch) => { | ||
const apiURL = 'https://react-learnwords-example.herokuapp.com/words'; | ||
dispatch(fetchDictionaryStart()); | ||
try { | ||
const res = await fetch(apiURL); | ||
const words = await res.json(); | ||
dispatch(fetchDictionarySuccess(words)); | ||
} catch (e) { | ||
dispatch(fetchDictionaryError(e)); | ||
} | ||
}; | ||
} | ||
export const fetchDictionary = () => async (dispatch: Dispatch) => { | ||
const apiURL = 'https://react-learnwords-example.herokuapp.com/words'; | ||
dispatch(fetchDictionaryStart()); | ||
try { | ||
const res = await fetch(apiURL); | ||
const words = await res.json(); | ||
dispatch(fetchDictionarySuccess(words)); | ||
} catch (e) { | ||
dispatch(fetchDictionaryError(e)); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters