Skip to content

export json to csv in react#204

Open
Nazaqat wants to merge 2 commits into
developfrom
react-csv
Open

export json to csv in react#204
Nazaqat wants to merge 2 commits into
developfrom
react-csv

Conversation

@Nazaqat
Copy link
Copy Markdown
Collaborator

@Nazaqat Nazaqat commented Apr 22, 2020

No description provided.

@Nazaqat Nazaqat self-assigned this Apr 22, 2020
@Nazaqat Nazaqat linked an issue Apr 22, 2020 that may be closed by this pull request

// Fetching data from endpoint
const getRequest = async function() {
const jsonUrl = 'https://jsonplaceholder.typicode.com/users';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the jsonUrl a prop? it will be easier to share with other graphs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if json returns empty ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export JSON into CSV

4 participants