Ability to get children of req object
See original GitHub issueI’m trying to set a variable as the value of either req.body.token
, req.query.token
, or req.headers['x-access-token']
in a middleware function, but I’m running into issues.
In Express, this works:
const app = express()
function apikey(req, res, next) {
let userToken = req.body.token || req.query.token || req.headers['x-access-token']
if (!token) return res.status(401).end('no token provided')
next()
}
app.use(apikey)
If a token is present in the body, it uses that, and so on.
When I try the equivalent in Polka, I’m getting a TypeError: Cannot read property 'token' of null
When I use the Async example expressed in the README I actually get the same error.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Pass and access request response object in child process ...
The problem with passing the request/response between parent and child is that you have to be able to serialize the objects sent back...
Read more >Working with the request object in Express.js
When an HTTP request comes in, Express middleware methods have full access to request and response so they can modify those objects.
Read more >How To Use the req Object in Express - DigitalOcean
Learn about using the req object in Express.js projects to examine calls from the client side, make HTTP requests, and handle incoming data ......
Read more >Express.js req.body Property - GeeksforGeeks
The req. body property contains key-value pairs of data submitted in the request body. By default, it is undefined and is populated when...
Read more >Pass handle representing request/response to child process
I have a Node.js server (running on Node version 9) and I want to launch a child process for a certain type of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m patching it now 😃
Available in
0.3.4
😄