0

I am trying to convert the 'Data' structure element from apollo hook call to an array I can pass to render in React. Here is my hook call using the '@apollo/react-hooks' library. const { data, loading, error } = useQuery(findTokenQuery)
How can I convert the recieved Data structure element... {"id":4,"element":"TITANIUM","symbol":"TI"} to an array like [{id: 4, element:"TITANIUM",symbol:"TI"] ?

John Worthley
  • 93
  • 1
  • 1
  • 7

1 Answers1

1

You can wrap the result in an array after it's destructured:

const arr = [data]

And then iterate over arr.

Jay Kariesch
  • 1,392
  • 7
  • 13