Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not receiving all the fields in the data #85

Open
ayezinzu opened this issue Jan 11, 2021 · 2 comments
Open

Not receiving all the fields in the data #85

ayezinzu opened this issue Jan 11, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ayezinzu
Copy link

Hey guys m using the trefle api.
this is my code

const fetchData = async () => {
 const response = await fetch(`https://trefle.io/api/v1/plants?token=T_uA0qXw0b6uLOiVNsXf7Dns8h5iwLr-MYHgD4fidaA&filter[common_name]=wheat`);
  const json = await response.json();
  return json
}
const fetchedData = fetchData().then((data) => {
    console.log(data.data)
})```
this is the data I get 
```[
  {
    id: 190066,
    common_name: 'Wheat',
    slug: 'triticum-urartu',
    scientific_name: 'Triticum urartu',
    year: 1972,
    bibliography: 'Bot. Zhurn. (Moscow & Leningrad) 57: 176 (1972)',
    author: 'Thumanjan ex Gandilyan',
    status: 'accepted',
    rank: 'species',
    family_common_name: 'Grass family',
    genus_id: 134,
    image_url: 'https://d2seqvvyy3b8p2.cloudfront.net/138572776e13fbd25318bb29988915bf.jpg',
    synonyms: [
      'Triticum urartu var. libanicum',
      'Crithodium urartu',
      'Triticum urartu var. pubescentinigrum',
      'Triticum urartu var. pubescentiurartu',
      'Triticum urartu var. turcicum',
      'Triticum urartu var. binarturutriru'
    ],
    genus: 'Triticum',
    family: 'Poaceae',
    links: {
      self: '/api/v1/species/triticum-urartu',
      plant: '/api/v1/plants/triticum-urartu',
      genus: '/api/v1/genus/triticum'
    }
  }
]```
but in the docs, these is all the fields https://docs.trefle.io/docs/advanced/plants-fields

like why does my data only some fields from the one mentioned in there
@ayezinzu ayezinzu added the bug Something isn't working label Jan 11, 2021
@sarahbayley
Copy link

[Apologies for reposting this; I realised later I was not on my personal account.]

@ayezinzu If I'm understanding your issue correctly, you're getting a filtered list of results (though there is only 1 result for filter[common_name]=wheat), so you're getting the basic "front page" data. To get all the fields described in the docs, you then need to go to that plant's page, either using one of the links:

https://trefle.io/api/v1/plants/triticum-urartu?token=T_uA0qXw0b6uLOiVNsXf7Dns8h5iwLr-MYHgD4fidaA
https://trefle.io/api/v1/species/triticum-urartu?token=T_uA0qXw0b6uLOiVNsXf7Dns8h5iwLr-MYHgD4fidaA

Or its ID:

https://trefle.io/api/v1/species/190066?token=T_uA0qXw0b6uLOiVNsXf7Dns8h5iwLr-MYHgD4fidaA

Does that make sense, or am I misunderstanding your question? I'm able to access all the fields described.

@mmeyers3
Copy link

Hi. I am struggling to pull information about the plants like their minimum temperature. I think this is the data that is missing when making calls to the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants