AndreasFaust / gatsby-source-custom-api

Source data from any API and transform it to (File-)Nodes.
52 stars 25 forks source link

I want to get only first 3 elements from an array. Is that possible ? #41

Open ShuvoHabib opened 2 years ago

ShuvoHabib commented 2 years ago

Let's say we're getting an array of 5 items from the API. Can we get only 3 items, not all the 5 items?

{
  "data": {
    "finance": {
      "data": [
        {
          "id": "590522000022443198",
          "City": "Melaka"
        },
        {
          "id": "590522000025688127",
          "City": "Limassol"
        },
        {
          "id": "590522000037762639",
          "City": "Cyberjaya"
        },
        {
          "id": "590522000037762487",
          "City": "Labuan"
        },
        {
          "id": "590522000022432183",
          "City": "Ipoh"
        }
      ]
    }
  },
}
MuhammadHadiofficial commented 2 years ago

If you are talking about graphql then you can add limit in your query and limit it to n number of elements in the results.