Fetch Headers and Why They Matter

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • If you have ever used fetch or XMLHttpRequest then you have worked with HTTP Requests and HTTP Responses. That also means that you have been working with Headers, which are an integral part of every Request and Response.
    This tutorial explains how you can find the headers, their values, and then use that as part of your fetch process.
    Code from Video: gist.github.co...
    MDN reference for the Headers object: developer.mozi...

Комментарии • 27

  • @Gollumfili
    @Gollumfili 2 года назад +2

    Love how these videos are kept as simple as possible, but are still explained properly without all the waffle. Definitely my go to channel.

  • @codesader5720
    @codesader5720 3 года назад +4

    This is powerful. I have always known there was more to the headers. I just didn't know it was this much. I bet this is just even a tip of the iceberg.
    Great content!

  • @biswamohandwari6460
    @biswamohandwari6460 3 года назад

    Everytime I visit this channel I always find something which I don't know and then starts to learn it🙂

  • @reanibutani9555
    @reanibutani9555 3 года назад +1

    This is the best explaination about headers

  • @paxdriver
    @paxdriver 2 года назад

    Correction, I think important for newbies: arrays are not key-value pairs, an array is an ordered list aka index-value pairs (arrays don't have named keys like objects do).
    Good vids, love your work, thanks a mil 👍

  • @ShreyasKumar
    @ShreyasKumar Год назад

    Love you Steve you are a true GEM. Thank you for your lovely tutorials. 🙂

  • @barungh
    @barungh 2 года назад

    Very very useful,
    I was looking into 'Lorem Picsum' - Rndom Image Generator API,
    and wanted to control the response
    Thank You so much.

  • @deependrasinghshekhawat2856
    @deependrasinghshekhawat2856 3 года назад

    I came in to learn something and with that learned something else as well. thanks as always.

  • @barungh
    @barungh 2 года назад

    Thanks!

  • @armin3529
    @armin3529 3 года назад

    That's us great man thanks ❤️❤️❤️

  • @tralalili_dwarf
    @tralalili_dwarf 3 года назад +1

    i'm sorry but something is confusing me in the code. but it's not realy related to the vid.
    how does a for of loop work with resp.headers
    if resp.headers is an object?
    doesn't a for of loop only works with itterables?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  3 года назад +1

      The headers object itself is iterable.
      It works the exact same way as if you used
      for( let entry of myHeaders.entries() ){ }
      developer.mozilla.org/en-US/docs/Web/API/Headers/entries

    • @tralalili_dwarf
      @tralalili_dwarf 3 года назад +2

      @@SteveGriffith-Prof3ssorSt3v3 I really appreciate the quick answer, steve.
      it helped a lot.
      thank you very much, i love your channel !!

  • @devstefancho
    @devstefancho 3 года назад

    awesome!

  • @oussamasethoum1665
    @oussamasethoum1665 2 года назад

    why tutorials doesn't touch the necessary part which is setting the headers in the request.

  • @pjmclenon
    @pjmclenon 2 года назад

    hello this does not work on a mobile or even any phone wifi for json why?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад

      Most likely you are missing the response header from the server. The client side code should work everywhere.

    • @pjmclenon
      @pjmclenon 2 года назад

      @@SteveGriffith-Prof3ssorSt3v3 hello i tried many differnt lines of code and it never worked Lisa

  • @joaovaz3473
    @joaovaz3473 3 года назад +2

    I'll be honest: I know nothing about headers except for what they are (I'd say some kind of array of information that's returned with a file) lmao

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  3 года назад +3

      That is actually a pretty good description. When you send an HTTP request it has a header, body, and footer. The HTTP response also has those three things. the body is where the uploaded or downloaded file (or formatted data) goes. The header is the description of where it is going, where it came from, and other meta information. The footer is for verifying that you have the whole thing.

  • @whyredvince
    @whyredvince 3 года назад

    You should start a blog.

  • @rajkumarvelumani6283
    @rajkumarvelumani6283 3 года назад

    Hi bro..
    How to fetch single data from database using JavaScript
    Make a video for this

  • @senseicodes
    @senseicodes 3 года назад

    First viewer😁