The project I'm trying to achieve the desired result within is a TypeScript, React project that's running Storybook.js.
I have a csv file that I've stored in the public folder of my React application. The csv contains date and value data that I would like to use to draw a graph for testing purposes.
As it stands im currently using the below function to fetch the data:
private fetchFromUrl = async() => {
const response = fetch(`${process.env.PUBLIC_URL}/tempData/data_for_damian.csv`)
.then(res => res.text())
.then(res => readString(res))
.then(res =>{
return(res.data)
})
return await response
}
Which returns:
Promise {<pending>}
__proto__: Promise
[[PromiseStatus]]: "fulfilled"
[[PromiseValue]]: Array(143816)
Plottable.js expects a table of coordinates in this format:
[
{ "x": 0, "y": 1 },
{ "x": 1, "y": 2 },
{ "x": 2, "y": 4 },
{ "x": 5, "y": 20 },
]
How do I extract the table of data from the promise?
Alternatively could I populate a table of values as part of the fetch function instead?