Why is my "hello world" disappearing after adding the connection code from MongoDB Atlas?
The code is fine and showing "Hello world!" on my 3000 port, and as soon as I add the mongoose.connect function, then the port 3000 goes blank and the "Hello world!" disappear. What could be happening?
Yes, I did install mongoose on package.json
`import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import reportWebVitals from "./reportWebVitals";
const mongoose = require("mongoose");
mongoose.connect(
"mongodb+srv://:@cluster0.gcyyo.mongodb.net/test?retryWrites=true&w=majority"
);
const partSchema = new mongoose.Schema({
partN: "string",
description: "string",
});
const Part = mongoose.model("Part", partSchema);
ReactDOM.render(
Hello world!
,
document.getElementById("root")
);`
Top comments (3)
Apparently it doesn't like the import {render} syntax
and I don't know why I can't even upload an image... but this is the error:
Compiled with problems:X
ERROR in ./src/index.js 8:0-6
export 'render' (imported as 'render') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, version)
Well.. thanks.. I will try that... as soon as I solve another problem that I will post on it.. :P getting tons of errors after I npm mongoose
I ended up using something like below from the mongoose docs.
I think it is working because it isn't breaking my "hello world"... I'll try to manipulate some data later see if I have an actual working connection.
```const mongoose = require('mongoose');
main().catch(err => console.log(err));
async function main() {
await mongoose.connect('mongodb://localhost:27017/test');
}```