nascentdigital / contentfully

A simple but performant REST client for Contentful.
MIT License
18 stars 7 forks source link

Method `getModel(id: string)` fails silently #21

Closed twillw closed 5 years ago

twillw commented 5 years ago

The getModel(id: string) method calls _parseEntries(json.items, links, multiLocale) however when fetching a single model contentful doesn't return an items key in the json. Ex:

{
  "sys": {
    "space": {
      "sys": {
        "type": "Link",
        "linkType": "Space",
        "id": "07ji7vj2yk96"
      }
    },
    "type": "Entry",
    "id": "1oZUuIStCIK4hbho8VRvvk",
    "contentType": {
      "sys": {
        "type": "Link",
        "linkType": "ContentType",
        "id": "article"
      }
    },
    "revision": 0,
    "createdAt": "2019-07-03T17:12:37.261Z",
    "updatedAt": "2019-07-04T21:31:18.135Z",
    "environment": {
      "sys": {
        "id": "master",
        "type": "Link",
        "linkType": "Environment"
      }
    },
    "locale": "en-US"
  },
  "fields": {
    "imagethumb": {
      "sys": {
        "type": "Link",
        "linkType": "Asset",
        "id": "4wZGcaQygMLFwji3F0v44t"
      }
    },
    "title": "Harnessing tech to tackle homelessness: Meet CG Chen! ",
    "body": "[Ample Labs](https://amplelabs.com \"Ample Labs\") is a non-profit empowering those of us who are experiencing homelessness through technology... "
  }
}

The getModel method just ends up returning an empty array for this response.

abraini-Nascent commented 5 years ago

Solved in version 1.4.2. Thanks!