Angular 2 Tutorial (2016) - HTTP (GET and POST to RESTful Service)

I have the following code that returns data (it requires user auth detail & product Id as part of the request). I want to add caching to enable a quicker response time. In order to enable caching, should it be a GET request, bearing in mind that I am transmitting tokens to authenticate and don't like the idea of passing tokens in URL. Happy to leave as POST but read somewhere that Post request should not be used for caching, hence the confusion.'/data', userAuth, (req, res) => { var productId = req.body.productId; if (!validate.STRING(productId)) { res.apiError(messages.server.invalid_request); } else { dbProduct.findOne({ productId: productId }).then(dbRes => { if (dbRes !== null) { res.apiSuccess({ assetImages: dbRes.assetImages, productStatus: dbRes.productStatus, createdDate: dbRes.createdDate, title: dbRes.title, details: dbRes.details, features: dbRes.features, }); } else { res.apiError(messages.product.not_found); } }); } 


Pracoval pro vás: Charles Robertson | Chcete nás kontaktovat?

užitečné informace