request.response.source
now I need to access with request.response.source.payload
. I'm having difficulty identifying when and where that change was introduced. Could someone provide some insight. Thank you.
let refreshData = function () {
server.methods
.search(deepCopy(AllProjectsQuery.query), null, "USE_CACHE")
.then((data) => {
logger.log('info', 'refresh all projects data succeed')
})
.catch((err) => {
logger.log('error', 'refresh all projects data error: %s', JSON.stringify(err))
})
}
access-control-allow-origin
et al. are working ok, but how do I configure Access-Control-Allow-Methods
? I'm currently generating *-methods header in my plugin, but just I'd prefer to use HAPI CORS config for this if possible.
pendingGenerateTimeout
property? No matter what value I set or not defining it, I can't seem to get concurrent access to a cache item working. It always queues it up and the same object is returned. Here's the sample code. I try to access /route1 and then wait a few seconds then access /route2, but they both return the same exact item. I would expect that since there is no cached item initially, that the calls to /route1 and /route2 should return different objects? function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
const querySchemaMetadata = async () => {
console.log(`regenerating cache ${(new Date()).toLocaleTimeString()}`);
await sleep(9000);
return Promise.resolve([{id: `${(new Date()).getMilliseconds()}`}]);
};
server.method('querySchemaMetadata', querySchemaMetadata, {
cache: {
expiresIn: 60 * 60 * 1000, // 1hr
/**
* provides a 15 second timeout querySchemaMetadata to return. Otherwise, returns a timeout error
*/
generateTimeout: false,
//generateTimeout: 15 * 1000,
/**
* returns a wrapped object of the value that includes additional stats metadata
*/
getDecoratedValue: true,
/**
* allow multiple simultaneous access requests to this cache item to be queued for up to a duration of
* 10 seconds before a separate access request is allowed.
*/
pendingGenerateTimeout: 2000,
}
});
server.route({
path: '/route1',
method: 'GET',
handler: async function (request, h) {
await server.methods.querySchemaMetadata()
}
});
server.route({
path: '/route2',
method: 'GET',
handler: async function (request, h) {
await server.methods.querySchemaMetadata();
}
});