System Information
- Strapi Version: 3.2.5
- Operating System: Windows 10
- Database: MongoDB
- Node Version: v12.18.1
- NPM Version:
- Yarn Version: v1.22.4
Good morning, i am trying to create the strapi import plugin: How to create your own plugin on strapi (3/4). Everything is fine until point 3, when I implement:
1- “Open ImportContent.js file inside controllers directory, remove the default content and paste the following”:
"use strict";
module.exports = {
preAnalyzeImportFile: async ctx => {
const services = strapi.plugins["import-content"].services;
try {
const data = await services["importcontent"].preAnalyzeImportFile(ctx);
ctx.send(data);
} catch (error) {
console.log(error);
ctx.response.status = 406;
ctx.response.message = "could not parse: " + error;
}
}
};
2- “Open routes.json inside config directory and paste the following”
{
"routes": [
{
"method": "POST",
"path": "/preAnalyzeImportFile",
"handler": "ImportContent.preAnalyzeImportFile",
"config": {
"policies": []
}
}
]
}
Until that moment, I had not thrown any errors. When I implement the above two points, it throws me an error:
error TypeError: Cannot read property ‘preAnalyzeImportFile’ of undefined
I have tried to understand why, but I don’t have much experience to solve the problem.
Thanks in advance.