Commit a455c312 by jaymehta

.

1 parent 0574f7ae
......@@ -83,13 +83,26 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
console.log("should be here");
} else {
console.log("but is here");
let final;
let str = ctx.request.body.data.name
// console.log()
let newStr = str.replace(/ /g,'').toUpperCase().replace(/[^a-zA-Z ]/g, "")
if (newStr.length >= 4) {
final = newStr.slice(0, 4);
console.log(final+String(Math.floor(Math.random() * 90000) + 10000))
} else {
final = newStr
console.log(final+String(Math.floor(Math.random() * 90000) + 10000))
}
ctx.request.body.data.user = currentUser.id;
const response = await strapi.entityService.create("api::vendor.vendor", {
data: {
...ctx.request.body.data,
phone: ctx.request.body.data.mobileNo,
publishedAt: date,
uniqueVendorId: str
},
});
console.log("response", response);
......@@ -230,7 +243,7 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
async addVendorId(ctx) {
try {
// console.log(ctx.request.body)
} catch (error) {
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!