TransWikia.com

Error Invalid shorthand property initializer

Stack Overflow en español Asked by Cristian Saavedra on January 28, 2021

Hola tengo un problema compilar estas lineas de codigo:

module.exports = {
   Image = require('./image.js') 
};

Error Invalid shorthand property initializer

Esto va unido con lo otro pero en distintos archivos
const path = require(‘path’);
const {randomNumber} = require(‘../helpers/libs’);

const fs = require('fs-extra');
const { Image } = require('../models');
const ctrl = {};

ctrl.index = (req, res) => {

};
ctrl.create = async (req, res) => {
     const imgUrl = randomNumber();
     console.log(imgUrl);
     const imageTempPath = req.file.path;
     const ext = path.extname(req.file.originalname).toLowerCase();
     const targetPath = path.resolve(`src/public/upload/${imgUrl}${ext}`);

     if(ext === ".png" || ext === ".jpg" || ext === ".jpeg" || ext === ".gif" || ext === ".svg" || ext === ".tiff" || ext === ".tif") {
       await fs.rename(imageTempPath, targetPath);
      const newImg = new Image({
            title: req.body.title,
            description: req.body.description,
            filename: imgUrl + ext
       });
       console.log(newImg);
     }
     res.send("Recibido");
};
ctrl.like = (req, res) => {

};
ctrl.comment = (req, res) => {

};
ctrl.remove = (req, res) => {

};

module.exports = ctrl;

me seria de mucha ayuda que me ayudaran porfavor

One Answer

no tenes definido ni randomNumber ni Path, en este archivo image.js

const path = require("path");
const { randomNumber } = require("../helpers/libs");
const fs = require("fs-extra");
const { Image } = require("../models");

const ctrl = {}

Answered by user175122 on January 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP