You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a bit of an issue when trying to implement. My sample code is as follows:
var express = require('express');
var apicache = require('apicache');
apicache.options({ debug: true });
var cache = apicache.middleware();
var router = express.Router();
router.get('/test', cache('1 hour'), function (req, res) {
//code in here
};
When the app loads, I get the error 'Cannot read property 'x-apicache-bypass' of undefined'.
Any idea on what I might be missing?
The text was updated successfully, but these errors were encountered:
Hey @mwkrieger - you just need to not immediately execute the middleware function during your assignment. It should be:
varcache=apicache.middleware;
...instead. It's just a reference to the built in middleware function that you would pass to your route. There are lots of ways to write this of course, and if you wanted a single time duration through your entire routes, you could do something like:
notice that middleware only gets executed once in both cases (just in different spots). The return value of that execution is a true middleware function(req, res, next) signature, so if you accidentally execute it twice, there are no longer request/response objects captured (which apicache uses internally of course)
Hi,
Having a bit of an issue when trying to implement. My sample code is as follows:
When the app loads, I get the error 'Cannot read property 'x-apicache-bypass' of undefined'.
Any idea on what I might be missing?
The text was updated successfully, but these errors were encountered: