This week's book giveaway is in the XML and Related Technologies forum.
We're giving away four copies of Java XML & JSON and have Jeff Friesen on-line!
See this thread for details.
Win a copy of Java XML & JSON this week in the XML and Related Technologies forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

JavaScript webshop with MySQL DB  RSS feed

 
Master Rancher
Posts: 1043
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all except from the basic stuff I have no experience with javascript.
For a friend of mine I'm trying to make a small webshop in javascript but I have trouble connecting the app to my db.
I'm using npm mysql2 to do so. When I run only the javascriptcode everything works fine, so I'm sure the needed packages are installed and my dependencies are in order.
But when running the full website I get the console-error require is not defined.
After a search I read that require is runs serverside (What ever that means, I thought the whole point of js is that it is run in the browser) and the browser dosn't know what to do with it.
People suggest to use express or require.js.
I couldn't for the love of god don't find a good tutuorial that explains me how to us express ccombined with a db, all the expamples I've seen seemed to start a webserver.
So I tried to us require.js, but when doing so I get this error:



which means I should use require["mysql1", function("mysql2")], but when I trie to do so, my ide gives me an error saying that require has a wrong number of arguments.

Anyone who can point me in the right direction?
 
Marshal
Posts: 67224
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there actually a problem at run-time? IDE errors and warnings are notoriously unreliable.
 
Daniel Demesmaecker
Master Rancher
Posts: 1043
17
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear

As a mather of fact, it does, but not the one expected.


So apperently it's looking in the wrong directory.
I read online that you're suposed to list the dependend modules in the dependency array in the require.js file, but couldn't for the love of god find it...
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!