Conversation
|
|
||
| // Fetching data from endpoint | ||
| const getRequest = async function() { | ||
| const jsonUrl = 'https://jsonplaceholder.typicode.com/users'; |
There was a problem hiding this comment.
Can you make the jsonUrl a prop? it will be easier to share with other graphs.
There was a problem hiding this comment.
Hi Ricardo, Thank you for your suggestion - I ll look into that. But one other issue linked with code is, It works when I use external URL link 'https://jsonplaceholder.typicode.com/users' but I does not work on sensor reading endpoint #150 'http://localhost:3000/api/sensor-reading/' .
Component is lying in client/containers/export-data.
May its because of authentication / wrong folder placement or something else?
There was a problem hiding this comment.
There is good examples of consuming API running at your localhost https://dzone.com/articles/consuming-rest-api-with-reactjs
| // http://localhost:3000/api/sensor-reading/ | ||
| const res = await fetch(jsonUrl); | ||
| const json = await res.json(); | ||
|
|
There was a problem hiding this comment.
what if json returns empty ?
No description provided.