¿Cómo aceptar req.params que contienen múltiples ID? Quiero buscar y eliminar la identificación múltiple
aquí está mi código:
const id = req.params; const masterFunders = await masterFunder.findOne({ where: { id: ids } }) if (!masterFunders) { return res.API.error(RESPONSE_MESSAGE.file_not_found, 400) } if (masterFunders.createdAt.getTime() > new Date().getTime() - (1000 * 60 * 60 * 24 * 10 * 3)) { return res.API.error(RESPONSE_MESSAGE.cannot_delete_file, 400) } await masterFunder.destroy({ where: { id: ids } }); return res.API.success(RESPONSE_MESSAGE.success, 200) } catch (error) { console.log(error) return res.API.error(error.message)es un error
{ "status": false, "message": "Invalid value {\n id: '[de7cc75d-4925-4a8d-869c-9072c7310fc9, b9da8552-e3f9-4628-a5a2-9709399b20dc]'\n}", "meta": {} }"ids" parece ser una cadena que contiene una matriz en formato JSON, no una matriz de JavaScript.
Entonces debes hacer: ids = JSON.parse(ids); para convertir la cadena en una matriz de JavaScript :)