Cannot console log the properties of an object

Viewed 152

I'm tring to console log the propreties of an object in typescript but it's not working.

  setTitleAndBody(result: { title: String; body: String; }) {
    console.log(result)
    console.log(result.title)
  }

The most curious in this is that if I do it only for result, I can open the object in my app console and see the informations that are in title and body. But when I wanna console log directly result.title, it's not working. Any idea why this happens? I already tried other ways to access them like result["title"], still not working.

enter image description here

1 Answers

Add a setTimeout just like that:

  setTitleAndBody(result) {
    setTimeout(() => {
      this.setState({noteTitre: result.title})
      this.setState({noteCorps: result.body})
    }, 100)
  }
Related