fix: undef file
This commit is contained in:
parent
ac05d82e3a
commit
4912a872e0
1 changed files with 3 additions and 3 deletions
|
@ -49,10 +49,10 @@ async function handler(req: NextApiReq, res: NextApiRes, user: UserExtended) {
|
||||||
} else if (req.method === 'PATCH') {
|
} else if (req.method === 'PATCH') {
|
||||||
if (!req.body.id) return res.badRequest('no file id');
|
if (!req.body.id) return res.badRequest('no file id');
|
||||||
|
|
||||||
let image;
|
let file;
|
||||||
|
|
||||||
if (req.body.favorite !== null)
|
if (req.body.favorite !== null)
|
||||||
image = await prisma.file.update({
|
file = await prisma.file.update({
|
||||||
where: { id: req.body.id },
|
where: { id: req.body.id },
|
||||||
data: {
|
data: {
|
||||||
favorite: req.body.favorite,
|
favorite: req.body.favorite,
|
||||||
|
@ -61,7 +61,7 @@ async function handler(req: NextApiReq, res: NextApiRes, user: UserExtended) {
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (file.password) file.password = true;
|
if (file.password) file.password = true;
|
||||||
return res.json(image);
|
return res.json(file);
|
||||||
} else {
|
} else {
|
||||||
if (req.query.count) {
|
if (req.query.count) {
|
||||||
const count = await prisma.file.count({
|
const count = await prisma.file.count({
|
||||||
|
|
Loading…
Reference in a new issue