Including Express In My React Project Gives Prototype Undefined Error
I'm trying to setup a simple react project that will connect to a MySql database. I require 'express', rebuild and at that point I try pulling up the project in the browser and get the following error:
"Uncaught TypeError: Cannot read property 'prototype'of undefined"
I tried stripped everything out of my app.js file and tried include express all by itself. Same error.
When I tried HapiJs I get the same error, just on a different line of code in my main js file.
You can't require express or hapijs in react app. React is for frontend. Express is server, backend framework. You have to run express as server, and communicate your react app by ajax calls nExpress is server, backend framework. You have to run express as server, and communicate your react app by ajax calls with express api.
Edit: OP ask how he can create server app and client app and communicate them. This is very broad subject. I can't teach you this in one answer. You should study:
- how to create express server app with routes. (simple tutorial express + mongodb : http://adrianmejia.com/blog/2014/10/01/creating-a-restful-api-tutorial-with-nodejs-and-mongodb/)
- how to create react client app.
- how to run in server your react app
- hot to communicate react whit server api endpoints.
For 2. 3. 4. in this react tutorial they show how to create app and use jquery to ajax calls : https://facebook.github.io/react/docs/tutorial.html
- → I can't do a foreign key, constraint error
- → How to implement DbDongle::convertTimestamps as workaround of invalid timestamps with MySql strict
- → MySQL error "Foreign key constraint is incorrectly formed"
- → Eloquent Multitable query
- → "Laravel 5.1" add user and project with userId
- → Database backup with custom code in laravel 5 and get the data upto 10 rows from per table in database
- → Laravel 5.1 QueryException when trying to delete a project
- → Using Array in '->where()' for Laravel Query Building
- → Chaining "Count of Columns" of a Method to Single Query Builder
- → Laravel Eloquent Joining Strange query
- → convert time using mysql laravel 5
- → How to update a column after an expiration date in MySQL?
- → Foreign key constraint fails on existing key