Monday, 24 April 2017

send user to angular route from nodejs function

I have a shopping cart app, that upon submission of payment does several things on the backend in NodeJS:

  1. Checks for existing customer (creates one if new)
  2. Charges the customer for the items in the cart
  3. Logs the order
  4. Registers players for each event purchased
  5. Sends confirmation emails to players
  6. Routes them to the checkout-success page, and empties the cart (which is in ngStorage)

My problem is with the last step. I'm not sure how to get the #/checkout-success route to load, as my code is incorrect:

var saveRegistrations = function(registrations, req, res) {
    Registration
    .collection.insert(registrations).then(function(r) {
    console.log("Successfully saved registrations!",r.insertedCount);
    res.redirect("#/checkout-sucess").json(registrations);
    })
    .catch(function(err) {
      console.log(err.stack);
    });

I already have the checkout-success.html file created, as well as the controller and have the route setup like I do my other angular routes in the app.js file. How can I send the user to this route and send that registrations JSON data along with it so I can finish things?



via user3561890

No comments:

Post a Comment