log errors react

Solutions on MaxInterview for log errors react by the best coders in the world

showing results for - "log errors react"
David
20 Jul 2020
1componentDidCatch(error, info) {
2    this.reactError = error
3    console.log(info)
4    this.setState({ catchError: true })    
5}
6
7
8sendError() {
9    fetch('/errorlog', {
10        headers: {
11            'Accept': 'application/json',
12            'Content-Type': 'application/json'
13        },
14        method: "POST",
15        body: JSON.stringify({ message: this.props.type + ' - ' + this.props.error.message, stack: this.props.error.stack })
16    })
17}
18