How to call REST API from custom widget

0
i've created a custom pluggable widget for gojs. my custom widget need to get data from api. i try add datasource property.   in datasource, i call workflow that call rest api and return output based on import mapping. i try with list view and my custom widget. with the same microflow listview can show correct output. but my custom widget has diferent output.  
asked
1 answers
2

There is two stages for getting data in custom widget. In first stage you will get ("status":"loading") in this case you will not receive data. In second stage you will get ("status":"available") in this case you will get your data .

 

You need to call a useEffect hool in your react code and pass the dependencies in dependency array.

 

useEffect(()=>{
  try{
    // Get you data here

}catch(err){
console.log(err)
}

},[<datasourceKey>.status]);

Make sure you replace <datasourcekey> to your key.

 

Please accept the answer if it helps you.

 

answered