I have a function in my React code defined like this:
getAttachment(url) {
fetch(url).then((responseText) => {
var response = responseText.json();
response.then(function(response){
this.setState({ attachment: response });
});
}.bind(this));
}
But I get an error when this compiles, saying that I have an unexpected token at the .bind(this)
. Any ideas, how to set state inside a promise?