Git Product home page Git Product logo

Comments (6)

lukeed avatar lukeed commented on September 23, 2024

This is plain JavaScript mechanics.

You can verify this in your Chrome devtools console too.

Headers (and Map, and FormData, and ...etc) print an empty {} by default. You have to actually convert it to an object or array of pairs first.

Options:

console.log([...req.headers]);
console.log(Object.fromEntries(req.headers));

Hope that helps!

from worktop.

joebailey26 avatar joebailey26 commented on September 23, 2024

Perfect. Thanks!

from worktop.

janat08 avatar janat08 commented on September 23, 2024

Can't this be fixed with a proxy that does the conversion?

from worktop.

lukeed avatar lukeed commented on September 23, 2024

Not going to happen, sorry. Sticking with raw primitives as they're being converged upon everywhere

from worktop.

janat08 avatar janat08 commented on September 23, 2024

I don’t understand, aren’t proxies just magical enough to let noobs play without understanding what’s happening underneath?

from worktop.

lukeed avatar lukeed commented on September 23, 2024

It's overhead and boilerplate needed for hardly any gain, and you end up reimplementing a bunch of stuff you would have gotten for free. Plus most people probably wouldn't need it, so it all goes to waste.

Doing Object.fromEntries(req.query) is straight forward and working with native JS APIs, as designed.

from worktop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.