1

I couldn't map the second API response https://api.coingecko.com/api/v3/global with error prompted (read property 'map' of undefined), while the first API is fine. Whats the issue here?

export default function Home(props) { const { data } = props.result; const { global } = props.nextResult; <table className="table2 table-hover table-dark"> <thead> <tr> <th>Markets</th> </tr> </thead> <tbody> {global.map (gg => ( <tr key={gg.endedicos}> <td>{gg.markets}</td> </tr> ))} </tbody> </table> export async function getServerSideProps(context) { const params = { order: CoinGecko.ORDER.MARKET_CAP_DESC }; const [result, nextResult] = await Promise.all([ coinGeckoClient.coins.markets({params}), coinGeckoClient.global() ]); return { props: { result, nextResult }, } } 
5
  • The error tells you that global is undefined. If you log nextResult to the console inside getServerSideProps, do you get the expected output? Commented May 30, 2021 at 17:08
  • nope, i got error from the log returned. But with direct http api.coingecko.com/api/v3/global , result is fine. Weird.. Commented May 31, 2021 at 6:35
  • What error do you get? Commented May 31, 2021 at 10:15
  • Error Unexpected token u in JSON at position 0 Commented May 31, 2021 at 10:36
  • Have a look at Uncaught syntax error unexpected token u JSON. Something's wrong with the request/response. Commented May 31, 2021 at 10:43

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.