1

我无法映射第二个 API 响应https://api.coingecko.com/api/v3/global并提示错误(read property 'map' of undefined),而第一个 API 很好。这里有什么问题?

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
    },
  }
}

4

0 回答 0