1.2.2 • Published 2 years ago
strapi-parse v1.2.2
strapi-parse
strapi-parse is an NPM package that can be used to parse Strapi V4 API responses into easier to work with objects.
Usage
$ npm i --save strapi-parse
import { strapiParse } from "strapi-parse";
const parsedAPIResponse = strapiParse(strapiAPIResponse);
Examples
strapi-parse does not currently support getting data from the meta properties
Collection Type
// Strapi API Response { data: [ { id: 1, attributes: { title: "Test Article", slug: "test-article", // ... } }, { id: 2, attributes: { title: "Test Article 2", slug: "test-article-2", // ... } } ], meta: { // ... } }
// strapi-parse Output { id: 1 title: "Test Article", slug: "test-article", // ... }, { id: 2 title: "Test Article 2", slug: "test-article-2", // ... }
### Single Type
```javascript
// Strapi API Response
{
data: {
id: 1,
attributes: {
title: "Test Article",
slug: "test-article",
// ...
},
meta: {
availableLocales: []
}
},
meta: { }
}
// strapi-parse Output
{
id: 1
title: "Test Article",
slug: "test-article",
// ...
}
Author
Joshua Henry - @jch-code