Skip to content

Commit

Permalink
examples/with-mongodb: avoid destructuring of environment variables. (#…
Browse files Browse the repository at this point in the history
…26029)

Greetings.

As per the [documentation](https://nextjs.org/docs/basic-features/environment-variables), we should not treat process.env as a Javscript Object & cannot destructure variables out of it. This PR avoid destructuring of environment variables in the `with-mongodb` example.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [x] Make sure the linting passes
  • Loading branch information
kasipavankumar committed Jun 13, 2021
1 parent 8afdaa3 commit 2477b13
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/with-mongodb/util/mongodb.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MongoClient } from 'mongodb'

const { MONGODB_URI, MONGODB_DB } = process.env
const MONGODB_URI = process.env.MONGODB_URI
const MONGODB_DB = process.env.MONGODB_DB

if (!MONGODB_URI) {
throw new Error(
Expand Down

0 comments on commit 2477b13

Please sign in to comment.