System Information
- Strapi Version: 3.5.1
- Operating System: Ubuntu 20.04
- Database: MongoDB Atlas
- Node Version: 14.15.5
- NPM Version: 6.14.11
- Yarn Version: 1.22.5
I need to import 10k articles to a content type, I already tried this plugin and It didn’t work, says please wait and then does not import anything. I also tried following this video and it throws this error: error TypeError: Cannot read property '_text' of undefined
.
I would appreaciate any help Its been two days trying to import a simple json file,
the json file is structured as an object thats why I have to pass it like that on the forEach otherwise I will get an error saying that is not a function.
PD: If It helps, I’m getting the json file from a postgress db with prisma.
PD2: removing the _text part, removes the error but creates an empty entry.
this is the code I am using on config/functions/bootstrap.js:
"use strict";
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*
* See more details here: https://strapi.io/documentation/developer-docs/latest/concepts/configurations.html#bootstrap
*/
module.exports = () => {
const posts = require("fs").readFileSync("./data/allposts.json", "utf8");
const data = JSON.parse(posts);
Object.keys(data).forEach((entry) => {
strapi.services.post.create({
title: entry.title._text,
});
});
};