Hessah
Hessah

Reputation: 309

Cloudinary configuration is not read data from .env file

I'm using Cloudinary with my node.js project...

The issue is cloudinary.config is not reading data from .env file, I have to type them directly!

const cloudinary = require("cloudinary");

cloudinary.config({
  cloud_name: process.env.CLOUD_NAME,
  api_key: process.env.CLOUD_API_KEY,
  api_secret: process.env.CLOUD_API_SECRET,
});

cloudinary.v2.uploader.upload(
  file.tempFilePath,
  { folder: "test" },
  async(err, result) => {
    if(err) throw err;
    console.log(result);
  }
);

I'll be thankful if anyone can help 🙏🏻

Upvotes: 0

Views: 600

Answers (1)

Hessah
Hessah

Reputation: 309

Issue is solved with adding require("dotenv").config(); to the beginning of the same file which contains cloudinary.config

Upvotes: 0

Related Questions