Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

59
Vistas
How to specify library version when using import in js?

I am trying to import cloudinary to my project, and in their documentation it says that I have to use require and specify the version to v2 like this const cloudinary = require("cloudinary").v2;. However, I have specified that my type in package.json as 'module', so I cannot use require I only have to say import. so, my question is how do I specify the version to v2. currently, I can upload to the cloudinary server, but I cannot get back the link to it. here is my cod:

my configuration

import multer from "multer";
import cloudinary from "cloudinary";
import { CloudinaryStorage } from "multer-storage-cloudinary";
import dotenv from "dotenv";

cloudinary.config({
  cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
  api_key: process.env.CLOUDINARY_KEY,
  api_secret: process.env.CLOUDINARY_SECRET,
});
const storage = new CloudinaryStorage({
  cloudinary: cloudinary,
  params: {
    folder: "ecommerce",
  },
});
const upload = multer({ storage: storage });

my route

productsRoutes.post("/products", upload.single("image"), async (req, res) => {
  console.log(req.file);
});

currently, the console log prints nothing when I submit the image, but it does upload it to the server.

sorry if my question is badly formatted, and any help is greatly appreciate it.

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos