Fetch inside "cells"

Tags: #<Tag:0x00007efc6d8a1e00> #<Tag:0x00007efc6d8a1770>

Is it possible to do fetch inside cells Hook? I am trying to get some data from Node JS server but I get this error: TypeError: Failed to fetch

Thanks.

Hi @jelm48

Can you share an example of your current implementation?

Hi @adrian.szymanski

cells={function (row, col) {

      let cellProperties = []          

     
      fetch('http://localhost:3001/usuarios-registrados', {

        method: 'GET',

        headers: { "Content-Type": "Application/json", "Accept": "application/json" }

      })

        .then(response => response.json())

        .then(users => users.forEach(element => {

          if (element.email === cookies.get('email')) {

            if (row === 10 && col === 10) {

              cellProperties.renderer = customRenderer

            }

          }

        }))

        .catch(error => console.log("No funcionó el fetch ", error))

      return cellProperties

    }}

Hi @jelm48

Thank you. Generally it is possible to fetch data inside the hooks. Here’s simplified example from our documentation where we are fetching the data inside afterChange hook: https://jsfiddle.net/aszymanski/b9ysgnkc/

I can’t fully check your example as you’re getting the data locally.

Thank you @adrian.szymanski

Please, close this topic.

Kind regards.