monorepo
monorepo copied to clipboard
2. Onboarding Fetch Examples
Tasks
- [x] Create a new branch from
dev
with your usernameonboarding/fetch-<username>
- [x] Write your code directly in the examples files
-
packages/ui/src/examples/E1_FetchWithAxios.tsx
-
packages/ui/src/examples/E2_FetchWithStrapiRequest.tsx
-
packages/ui/src/examples/E3_FetchWithFilters.tsx
-
- [x] See results in Storybook (
yarn storybook
)
Example
https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#filtering
const qs = require('qs');
const query = qs.stringify({
filters: {
username: {
$eq: 'John',
},
},
}, {
encodeValuesOnly: true, // prettify URL
});
await fetch(`http://localhost:1337/api/users?${query}`);
// http://localhost:1337/api/users?filters[username][$eq]=John