Error appears while trying to send POST request with PostgreSQL/Sequelize what could be the problem here?
async create(req, res, next) {
try {
let { name, price, brandId, typeId, info } = req.body;
const { img } = req.files;
let fileName = uuid.v4() + ".jpg";
img.mv(path.resolve(__dirname, "..", "static", fileName));
const device = await Device.create({
name,
price,
brandId,
typeId,
img: fileName,
});
return res.json(device);
} catch (e) {
next(ApiError.badRequest(e.message));
}
}
}
The error checks are failing: You are providing a string where an Integer is expected. What causes it is uncertain unless you provide the interface for Device.create(). Check the docs and make sure your input data has the correct types.
EDIT: The following thoughts were bogus There might also be a mix-up with your input: When using the shorthand object notation as you did, make sure your arguments have the right order. Depending on framework your input might just be wrong syntax, because you are essentially initializing an object with no keys but img. If your framework doesn't correct that, this might also be the error source.
But again, without further information on what the function call expects and what type your arguments have, debugging is fortune telling.