mern

Cannot Connect to MongDB Atlas using Mongoose

荒凉一梦 提交于 2020-01-03 04:16:50
问题 I am starting to learn a MERN stack tutorial. I initially created a react app, added a directory called backend, installed express, cors, express, and dotenv, then created a server.js and added some code, but after connecting to mongodb atlas, I get the error below: (node:5828) UnhandledPromiseRejectionWarning: MongoTimeoutError: Server selection timed out after 30000 ms at Timeout. (C:\Users\Lenovo\Desktop\REACTion\mernapp\backend\node_modules\mongodb\lib\core\sdam\topology.js:878:9) at

React Router 4 and props.history.push

北城以北 提交于 2019-12-20 03:15:22
问题 There's something driving me crazy in React, and I need your help. Basically, when the user clicks "My Profile", I want to redirect to the user's profile. To do that, I use the following snippet viewProfile = () => { console.log('My USER ID: ', this.props.userId); this.props.history.push(`/profile/${this.props.userId}`); } This should work. However, although the URL is changing to the correct URL when 'My Profile' is clicked, the page isn't appearing. It just stays as the old page. After

I am trying to create a new Cart schema with a request

余生长醉 提交于 2019-12-12 20:04:04
问题 My Data is not being saved correctly This is my SChema const mongoose = require('mongoose'); const ProductSchema = mongoose.Schema({ colorC: String, sizeC: String, date: Date, title: String, transactionID: Number, count: Number }); const CartSchema = mongoose.Schema({ products: [ProductSchema] }); const Cart = mongoose.model('Cart', CartSchema); module.exports = { cartModel: mongoose.model('Cart', CartSchema), productModel: mongoose.model('Product', ProductSchema) }; this is my post request

MERN Stack - Express and React on same port?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 03:24:03
问题 I'm working on a project with the MERN (MongoDB, Express, React, Node) stack and I'm having issues when posting data from a form within a React component to an API endpoint defined in Node.js. When I submit the form the browser just shows a CANNOT POST error. I'm pretty confident that if I create an event handler for the form submit within React and handle the POST using a library such as Axios that I could get around this issue. But ultimately I believe this problem is because the Node

React - Page doesn't display when using the browser back button

戏子无情 提交于 2019-12-08 05:11:25
问题 I have looked through a lot of related topics and have so far been unable to resolve my problem with my MERN app. When I try to go to another website and use the browser back button, some pages doesn't show. Instead, I can only see my json file / API response... I need to refresh the page for it to be displayed correctly. If, for example, you are going to : https://www.website.org/royalty-free-music/cinematic/page-1, try to go to another website and click to the go back button in your browser

Cannot Connect to MongDB Atlas using Mongoose

不羁岁月 提交于 2019-12-08 03:02:26
I am starting to learn a MERN stack tutorial. I initially created a react app, added a directory called backend, installed express, cors, express, and dotenv, then created a server.js and added some code, but after connecting to mongodb atlas, I get the error below: (node:5828) UnhandledPromiseRejectionWarning: MongoTimeoutError: Server selection timed out after 30000 ms at Timeout. (C:\Users\Lenovo\Desktop\REACTion\mernapp\backend\node_modules\mongodb\lib\core\sdam\topology.js:878:9) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7) (node:5828)

How to convert a html template to react?

橙三吉。 提交于 2019-12-03 09:08:26
问题 I have purchased an HTML admin template from themeforest (https://themeforest.net/item/limitless-responsive-web-application-kit/13080328?s_rank=1). I am building a MERN stack site, and wondering what would be the best way to convert this HTML template to a react site. Breaking down the template to components, adding routes manually, and converting HTML to JSX etc seems to be a tedious task. The question arises because in themeforest, the most popular admin templates were built for a jQuery /

How to convert a html template to react?

两盒软妹~` 提交于 2019-12-03 03:12:26
I have purchased an HTML admin template from themeforest ( https://themeforest.net/item/limitless-responsive-web-application-kit/13080328?s_rank=1 ). I am building a MERN stack site, and wondering what would be the best way to convert this HTML template to a react site. Breaking down the template to components, adding routes manually, and converting HTML to JSX etc seems to be a tedious task. The question arises because in themeforest, the most popular admin templates were built for a jQuery / HTML world, not for a full stack JS world. For example, the theme that I've linked above has ~7000

TypeError: this.state.patients.map is not a function

£可爱£侵袭症+ 提交于 2019-12-02 15:13:23
问题 i am new in react js,and i am learning to create a React application and I got a problem with mapping function: Here's my request and how I am attempting to render the data: class Patients extends Component { constructor(props) { super(props) this.state = { patients: [] } } componentDidMount() { api.getPatients() .then( patients => { console.log( patients) this.setState({ patients: patients }) }) .catch(err => console.log(err)) } render() { return ( <div className=" Patientss"> <h2>List of

TypeError: this.state.patients.map is not a function

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 08:12:20
i am new in react js,and i am learning to create a React application and I got a problem with mapping function: Here's my request and how I am attempting to render the data: class Patients extends Component { constructor(props) { super(props) this.state = { patients: [] } } componentDidMount() { api.getPatients() .then( patients => { console.log( patients) this.setState({ patients: patients }) }) .catch(err => console.log(err)) } render() { return ( <div className=" Patientss"> <h2>List of Patient</h2> {this.state.patients.map((c, i) => <li key={i}>{c.name}</li>)} </div> ); } } export default