Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #276 from strapi/fix-users-content-type
Browse files Browse the repository at this point in the history
Add support for user content type and file content type
  • Loading branch information
soupette authored Feb 9, 2022
2 parents a5b5595 + f2fb197 commit e1e6116
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/clean-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,13 @@ export const cleanAttributes = (attributes, currentSchema, schemas) => {
* @param {Object} ctx
* @returns {Object}
*/
export const cleanData = ({ id, attributes }, ctx) => {
export const cleanData = ({ id, attributes, ...rest }, ctx) => {
const { schemas, contentTypeUid } = ctx;
const currentContentTypeSchema = getContentTypeSchema(schemas, contentTypeUid);

return {
id,
...rest,
...cleanAttributes(attributes, currentContentTypeSchema, schemas),
};
};
2 changes: 1 addition & 1 deletion src/download-media-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const extractFiles = (text, apiURL) => {
* @param {Object} ctx
* @returns {String} node Id
*/
const downloadFile = async (file, ctx) => {
export const downloadFile = async (file, ctx) => {
const {
actions: { createNode, touchNode },
cache,
Expand Down
16 changes: 9 additions & 7 deletions src/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,17 @@ const fetchEntities = async ({ endpoint, queryParams, uid }, ctx) => {
`Starting to fetch data from Strapi - ${opts.url} with ${JSON.stringify(opts.params)}`
);

const {
data: { data, meta },
} = await axiosInstance(opts);
const { data: response } = await axiosInstance(opts);

const page = parseInt(meta.pagination.page);
const data = response?.data || response;
const meta = response?.meta;

const pagesToGet = Array.from({ length: parseInt(meta.pagination.pageCount, 10) - page }).map(
(_, i) => i + page + 1
);
const page = parseInt(meta?.pagination.page || 1, 10);
const pageCount = parseInt(meta?.pagination.pageCount || 1, 10);

const pagesToGet = Array.from({
length: pageCount - page,
}).map((_, i) => i + page + 1);

const arrayOfPromises = pagesToGet.map((page) => {
return (async () => {
Expand Down

0 comments on commit e1e6116

Please sign in to comment.