Skip to content Skip to sidebar Skip to footer

Const Url = {process.env.react_app_database} Syntaxerror: Unexpected Token

I have a file in mongo.js where I have set an ENV variable like so: const mongo = require('mongodb').MongoClient; const assert = require('assert'); const ObjectId = require('mongod

Solution 1:

This is not valid JavaScript syntax:

const url = { process.env.REACT_APP_DATABASE }

If you are creating an object literal, it needs to be in [key]:[value] format:

const url = { url: process.env.REACT_APP_DATABASE}

However, if you are trying to just get the variable:

const url = process.env.REACT_APP_DATABASE;

Post a Comment for "Const Url = {process.env.react_app_database} Syntaxerror: Unexpected Token"