Answer the question
In order to leave comments, you need to log in
How to display the values received from the server in React?
Good day. Cannot use server response.
import React from 'react'
import axios from "axios"
class NewTask extends React.Component{
constructor(props) {
super(props);
this.state = {
isLoading: true,
description: null,
task: null,
};
}
async componentDidMount() {
try {axios.get('http://localhost:5000/api/getTask')
.then((response)=>{this.setState({description: response.data.description})})
}
catch( error ) {
console.log(error);
}; }
render() {
var { isLoading, description, task} = this.state;
return(
<div className="createTaskWrap">
<p>Здесь ты можешь создать новый таск:</p>
<div className="desP"><p>{this.state.description}</p></div>
</div>
)
}
}
export default NewTask
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question