Updated functionality#50
Conversation
| constructor() { | ||
| super(); | ||
| this.state = { | ||
| apiKey: "db2b631c79deae1500162a294faec7dc", |
There was a problem hiding this comment.
never commit your API key. This should be in your .env file. Please revise https://bootcamp.rocketacademy.co/2-full-stack/2.2-advanced-react/2.2.7-environmental-variables
This is a big security risk and could potentially cost you thousands of dollars if it was another payable API.
| ) | ||
| .then((res) => { | ||
| this.setState({ | ||
| img: res.config.url, |
There was a problem hiding this comment.
Does this work? Since you do not return the axios request's result in the previous then block, I do not think this would work.
| console.log(weatherData.list); | ||
|
|
||
| for (const el of weatherData.list) { | ||
| this.state.output.push(el.dt_txt); |
There was a problem hiding this comment.
Here you directly push into a state variable. You should only use the setState function for this, and never directly update a state variable. This can lead to erratic behaviour in your app.
|
|
||
| renderTable() { | ||
| const data = this.state.output; | ||
| if (!data || data.length === 0) return null; |
There was a problem hiding this comment.
| if (!data || data.length === 0) return null; | |
| if (!data) return null; |
same thing
| /> */} | ||
|
|
||
| {/* <input type="submit" value="submit" onClick={this.handleSubmit} /> */} | ||
| {this.state.img !== "" ? ( |
There was a problem hiding this comment.
| {this.state.img !== "" ? ( | |
| {this.state.img ? ( |
No description provided.