Skip to content

jch-code/strapi-parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Version

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

// 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

License

MIT License

About

Parse Strapi V4 API responses into easier to work with objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published