System Information
- Strapi Version:
- Operating System:
- Database:
- Node Version:
- NPM Version:
- Yarn Version:
My Controller
makePayment: async (ctx, next) => {
try {
const {payee, account,period, packages} = ctx.request.body
const getAccount = await strapi.db.query("api::client.client").findOne({
select: ['name'],
where: { account: account}
})
const getPackageAmnt = await strapi.db.query("api::package.package").findOne({
select: ['amount'],
where: {name: `${packages}`}
})
const data = {
payee:payee,
account: getAccount['name'],
period: period,
packages: packages,
TotalAmnt: period * getPackageAmnt['amount']
}
const res = await strapi.entityService.create("api::payment.payment", {data:data})
return res
} catch (err) {
return err
}
}
My Response
{
"data": null,
"error": {
"status": 400,
"name": "ValidationError",
"message": "1 relation(s) of type api::package.package associated with this entity do not exist",
"details": {
"errors": [
{
"path": [],
"message": "1 relation(s) of type api::package.package associated with this entity do not exist",
"name": "ValidationError"
}
]
}
}
}