datocms / js-datocms-client

NodeJS/Browser client for DatoCMS
https://www.datocms.com
MIT License
72 stars 37 forks source link

Image returns different data since 0.5.0 #19

Closed tonicboy closed 6 years ago

tonicboy commented 6 years ago

It seems that the implementation of Image was changed since 0.5.0 (when it was moved to the new File.js) and it seems to return different data.

This is the result of an API call with 0.4.6: https://jsoneditoronline.org/?id=07e14f7ae68d4c29a853dcd9363af4f0

And this is what is returned in 0.5.0+ (tested all the way up to 0.5.6): https://jsoneditoronline.org/?id=9aa5ac585a7d42a2947a04f680ad2bb9

You can see that "featuredImage" used to be an entire image record but is now just the id of the record.

The JS client code remains unchanged:

const fetchNews = () => {
  const client = new SiteClient(process.env.DATO_API_TOKEN);

  const fetchEntries = () =>
    client.items.all({
      'filter[type]': 'news_entry',
      'page[limit]': 500
    });
  const fetchCategories = () =>
    client.items.all({ 'filter[type]': 'news_category', 'page[limit]': 500 });

  return Promise.all([fetchCategories(), fetchEntries()]);
};
stefanoverna commented 6 years ago

Yes, this is an expected behaviour, see https://www.datocms.com/changelog/cma-v2/