-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed api call by passing it thorugh a heroku project lol, fixed up r…
…edux form, rendering words on results page, added uuidv1
- Loading branch information
Showing
5 changed files
with
87 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -1,3 +1,16 @@ | ||
import axios from 'axios'; | ||
import { FETCH_WORDS } from './types'; | ||
import axios from "axios"; | ||
import { FETCH_WORDS } from "./types"; | ||
|
||
export const fetchWords = word => async dispatch => { | ||
const res = await axios.get( | ||
`${'https://cors-anywhere.herokuapp.com/'}https://od-api.oxforddictionaries.com:443/api/v1/wordlist/en/regions%3Dbritish%2C?word_length=4%2C&exact=false&limit=10`, | ||
{ | ||
headers: { | ||
'Accept': "application/json", | ||
'app_id': "4bb65adf", | ||
'app_key': "f0952a9ea06c8a6b1fc1bbb40a2e5688" | ||
} | ||
} | ||
); | ||
dispatch({ type: FETCH_WORDS, payload: res.data }); | ||
}; |
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 |
---|---|---|
@@ -1,30 +1,40 @@ | ||
import React from "react"; | ||
import React, { Component } from "react"; | ||
import { connect } from "react-redux"; | ||
import * as actions from "../actions"; | ||
import { Field, reduxForm } from "redux-form"; | ||
|
||
const Search = props => { | ||
const { handleSubmit, pristine, reset, submitting } = props; | ||
return ( | ||
<form onSubmit={handleSubmit}> | ||
<div> | ||
<label>First Name</label> | ||
class Search extends Component { | ||
render() { | ||
const { handleSubmit, pristine, reset, submitting, fetchWords } = this.props; | ||
return ( | ||
<form onSubmit={handleSubmit(values => fetchWords(values.firstWord))}> | ||
<div> | ||
<Field | ||
name="firstWord" | ||
component="input" | ||
type="text" | ||
placeholder="First Word" | ||
/> | ||
<label>First Name</label> | ||
<div> | ||
<Field | ||
name="firstWord" | ||
component="input" | ||
type="text" | ||
placeholder="First Word" | ||
/> | ||
</div> | ||
<div> | ||
<button type="submit" disabled={pristine || submitting}> | ||
Submit | ||
</button> | ||
</div> | ||
</div> | ||
<div> | ||
<button type="submit" disabled={pristine || submitting}> | ||
Submit | ||
</button> | ||
</div> | ||
</div> | ||
</form> | ||
); | ||
}; | ||
</form> | ||
); | ||
} | ||
} | ||
|
||
export default reduxForm({ | ||
form: "search" // a unique identifier for this form | ||
})(Search); | ||
export default connect( | ||
null, | ||
actions | ||
)( | ||
reduxForm({ | ||
form: "search" | ||
// onSubmitSuccess: afterSubmit | ||
})(Search) | ||
); |