How can JSON differ from blob?

  • 0
    I receive binary JSON from the server and depending on user actions blob. How can you tell them apart? Or do you need to write an additional entry point on the server?

    const res = await fetch('url')
    if await res.json():
          ...
    else:
          ...
    JavaScript Elliot McLean, Sep 26, 2019

  • 3 Answers
  • 0
    Typically, the response headers write the type
    Anonymous

  • 0
    let response = await fetch ('url');



    // get one heading

    alert (response.headers.get ('Content-Type')); // application / json; charset = utf-8
    Anonymous

  • 0
    This is usually written about in the docks to the API,
    Michael O'Rozco

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!