Conversation
|
You're missing one step. You've required the body-parser module, but you need to use the middle-ware function that calling bodyParser.urlencoded() returns. That middle-ware is responsible for extracting the post information and assigning it to the request.body object. It would look like this: alternatively, to be more explicit: // urlencoded returns a middle-ware function that you would then "use" |
|
Thanks for the earlier help. I tried to use underscore in client.js in order to sort the truckList, but I couldn't get var _ = require('underscore'); to work. Any suggestions? |
|
Using require() will only work using Node right now. There's a way to require code in client-side JavaScript, but it involves using another library to facilitate it such as Require.js or Browserify, which we won't have time to cover. Instead, what you want to do is add a script reference to the index.html that pulls in underscore. It will declare _ globally, so just make sure you include it before the client.js script reference. |
There was a problem hiding this comment.
Just add a script reference to index.html that includes the underscore library:
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
Make sure it appears before the client.js script reference.
|
👍 |
Hi James,
'Add Food Truck' is not working for me and I can't figure out why. If I add new truck info in the UI & click 'Add Food Truck', I get 'undefined' at the bottom of the truck list. Clicking on that gives me an empty object such as {"_id":"5553b545f7d30fa41db53471","__v":0,"payment":[],"schedule":[],"foodType":[]}
When I use Mongo to check the data, the empty object is there as well.
Any suggestions are welcome! (I've only worked on part 1 so far)
Thank you,
Diane