Skip to content

Instantly share code, notes, and snippets.

@jinwook-k
Last active September 21, 2020 04:37
Show Gist options
  • Save jinwook-k/680cbf213a62e2b557b3aaec2cc75d1f to your computer and use it in GitHub Desktop.
Save jinwook-k/680cbf213a62e2b557b3aaec2cc75d1f to your computer and use it in GitHub Desktop.
client/src/Components/WeatherForm.jsx
// imports
class WeatherForm extends Component {
// default state values
// componentDidMount()
// refreshSaveWeather()
// onChange()
// saveFormData()
// saveToLocalStorage()
saveToMongo = (event) => {
axios.post("/api/weatherMongo", {
zipCode: this.state.zipCodeInput,
tempMetric: this.state.tempMetric
}).then(response => {
let weatherData = response.data;
// do whatever you want with the weather data
});
}
render() {
return (
<Form className="weather-form" onSubmit={this.saveToMongo}>
...
</Form>
);
}
}
export default WeatherForm;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment