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
I have a service call that has a before and after hook.
The before gets some associated data (the data that is associated depends on a query parameter)
The after hook does some data processing to format the data for a front-end, the changes in the data are overwritten in the context.result
Before Hook
get: [
async function (context) {
log.info("calling: " + rootServiceName + "get - before");
//Call for basic learning pathway information
if (includeValue) {
//only select user information if getting basic user info
if(includeValue==1){
//select only needed fields
context.params.query.$select = ['id','firstName',"lastName","email","avatar","user_pathways"];
}else if(includeValue==2){
//don't select any user fields (not needed)
context.params.query.$select = ["user_pathways"]
}else{
// context.params.query.$select = ["id"];
}
//associated models to include
var associatedUserPathway = context.app.services['user_pathway'].Model;
var associatedPathway = context.app.services.learningpathway.Model;
var associatedSubjectLevel = context.app.services.subjectlevel.Model;
var associatedSubject = context.app.services.subject.Model;
var associatedUserContent = context.app.services['user_content'].Model;
var associatedContent = context.app.services.content.Model;
//map association includes
context.params.sequelize = {
raw:false,
include: [
{
model:associatedUserPathway,
include:[
{
model:associatedPathway,
include:[
{
model:associatedSubjectLevel,
include:[
{
model:associatedContent,
include:[
{model:associatedUserContent}
]
},
{
model:associatedSubject
}
]
}
]
}
]
}
]
};
}
// delete any special query params so they are not used
// in the WHERE clause in the db query.
delete context.params.query.include;
delete context.params.query.$call;
//return context;
}
]
After Hook
get: [
async function (context) {
log.info("calling: " + rootServiceName + "get - after");
//set input data to modify
var inputData = context.result;
// //--call functions--
//high level learning pathway information
function tier1data(){
//some data processing on inputData
}
//learning pathway info with subject levels
function tier2data(){
//some data process on inputData
}
//Call for basic learning pathway information
if (includeValue==1) {
tier1data();
}
else if (includeValue==2) {
tier2data();
}else if(includeValue){
context.result="Invalid Call Type";
}
//return context (async so that this occurs before function finishes)
return Promise.resolve(context);
}
]
Expected behavior
The expected behavior is that whenever I make a call with include=1 or 2, the after hook should run and return the processed data.
Actual behavior
When tested, this worked fine for individual calls in POSTMAN. I would always receive the processed data (based on the data processing in the after hook).
However in cases where we are using this API in a front end (we are using axios for REST calls), if there is a situation where API calls for the same endpoint are run in quick succession, intermittently the data is received as if only the before hook has run and not the after hook.
System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that's not working):
"@feathersjs/configuration": "^2.0.6",
"@feathersjs/errors": "^3.3.6",
"@feathersjs/express": "^1.3.1",
"@feathersjs/feathers": "^3.3.1",
"@feathersjs/socketio": "^3.2.9", NodeJS version:
v10.15.1 Operating System:
Windows 10
Browser Version:
Chrome 75.0.3770.142
The text was updated successfully, but these errors were encountered:
Steps to reproduce
I have a service call that has a before and after hook.
The before gets some associated data (the data that is associated depends on a query parameter)
The after hook does some data processing to format the data for a front-end, the changes in the data are overwritten in the context.result
Before Hook
After Hook
Expected behavior
The expected behavior is that whenever I make a call with include=1 or 2, the after hook should run and return the processed data.
Actual behavior
When tested, this worked fine for individual calls in POSTMAN. I would always receive the processed data (based on the data processing in the after hook).
However in cases where we are using this API in a front end (we are using axios for REST calls), if there is a situation where API calls for the same endpoint are run in quick succession, intermittently the data is received as if only the before hook has run and not the after hook.
System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that's not working):
"@feathersjs/configuration": "^2.0.6",
"@feathersjs/errors": "^3.3.6",
"@feathersjs/express": "^1.3.1",
"@feathersjs/feathers": "^3.3.1",
"@feathersjs/socketio": "^3.2.9",
NodeJS version:
v10.15.1
Operating System:
Windows 10
Browser Version:
Chrome 75.0.3770.142
The text was updated successfully, but these errors were encountered: