Commit 73e1c43a by jaymehta

update image query

1 parent 3440fe10
...@@ -66,7 +66,7 @@ module.exports = createCoreController("api::experience.experience", () => ({ ...@@ -66,7 +66,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
finalImageArray = [...finalImageArray, { image: element }]; finalImageArray = [...finalImageArray, { image: element }];
} }
ctx.request.body.data.imagesComponent; // ctx.request.body.data.imagesComponent;
// Create Activity // Create Activity
const activity = await strapi.entityService.create( const activity = await strapi.entityService.create(
"api::experience.experience", "api::experience.experience",
...@@ -157,7 +157,15 @@ module.exports = createCoreController("api::experience.experience", () => ({ ...@@ -157,7 +157,15 @@ module.exports = createCoreController("api::experience.experience", () => ({
throw new ValidationError("Category is a mandatory field"); throw new ValidationError("Category is a mandatory field");
} }
console.log("subcategoyr", ctx.params); console.log("subcategoyr", ctx.params);
let finalImageArray = [];
for (
let index = 0;
index < ctx.request.body.data.imagesComponent.length;
index++
) {
const element = ctx.request.body.data.imagesComponent[index];
finalImageArray = [...finalImageArray, { image: element }];
}
const subCategory = await strapi const subCategory = await strapi
.query("api::sub-categorie.sub-categorie") .query("api::sub-categorie.sub-categorie")
.findOne({ .findOne({
...@@ -217,6 +225,7 @@ module.exports = createCoreController("api::experience.experience", () => ({ ...@@ -217,6 +225,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
approved: ctx.request.body.data.approved, approved: ctx.request.body.data.approved,
// imagesComponent: ctx.request.body.data.imagesArrayComponent, // imagesComponent: ctx.request.body.data.imagesArrayComponent,
...ctx.request.body.data.daysBoolean, ...ctx.request.body.data.daysBoolean,
imagesComponent: finalImageArray,
}, },
}); });
console.log( console.log(
...@@ -229,13 +238,13 @@ module.exports = createCoreController("api::experience.experience", () => ({ ...@@ -229,13 +238,13 @@ module.exports = createCoreController("api::experience.experience", () => ({
// ? ctx.request.body.data.imagesArrayComponent // ? ctx.request.body.data.imagesArrayComponent
// : [ctx.request.body.data.imagesArrayComponent]; // : [ctx.request.body.data.imagesArrayComponent];
// console.log("imagesComponentData >", imagesComponentData); // console.log("imagesComponentData >", imagesComponentData);
const updatedExperienceImageComponent = await strapi.entityService.update( // const updatedExperienceImageComponent = await strapi.entityService.update(
"api::experience.experience", // "api::experience.experience",
id, // id,
{ // {
data: { imagesComponent: ctx.request.body.data.imagesComponent }, // data: { imagesComponent: ctx.request.body.data.imagesComponent },
} // }
); // );
console.log("updatedExperience", updatedExperience); console.log("updatedExperience", updatedExperience);
ctx.send({ ctx.send({
success: true, success: true,
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!