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've configured the context on ExpressJs app as a dependency on startup and also set it up as global middleware for every request.
The code works like a charm when using routing-controllers for Get, Put and Post
But, using @Body decorator into a PUT/POST method, it becomes undefined.
Also using body-parser, injecting decorator @JSON, the context get lost.
Working cases:
@get('/data')
public getData():Promise {
httpContext.get('contextId');//Got data
return new Promise;
}
@get('/data')
public getData(@Req() req):Promise {
httpContext.get('contextId');//Got data
var a = req.a;
return new Promise((resolve) => getData(a){
resolve(response);
});
}
@post('/data')
public setData():Promise {
httpContext.get('contextId'); //Got data
var a = 'some random data';
return new Promise((resolve) => setData(a){
resolve(response);
});
}
@post('/data')
public setData(@Req() req):Promise {
httpContext.get('contextId'); //Got undefined
var a = req.a;
return new Promise((resolve) => setData(a){
resolve(response);
});
}
Not working cases:
@UseBefore(json()) @post('/data')
public setData(@Req() req):Promise {
httpContext.get('contextId'); //Got undefined
var a = req.a;
return new Promise((resolve) => setData(a){
resolve(response);
});
}
@post('/data')
public setData(@Body() data):Promise {
httpContext.get('contextId'); //Got undefined
return new Promise((resolve) => setData(data){
resolve(response);
});
}
@put('/data')
public setData(@Body() data):Promise {
httpContext.get('contextId'); //Got undefined
return new Promise((resolve) => setData(data){
resolve(response);
});
}
The text was updated successfully, but these errors were encountered:
I've configured the context on ExpressJs app as a dependency on startup and also set it up as global middleware for every request.
The code works like a charm when using routing-controllers for Get, Put and Post
But, using @Body decorator into a PUT/POST method, it becomes undefined.
Also using body-parser, injecting decorator @JSON, the context get lost.
Working cases:
Not working cases:
The text was updated successfully, but these errors were encountered: