Why i have make another .then to pull a promiseValue from fetch promiseWhy does .json() return a promise?How do you access the matched groups in a JavaScript regular expression?Change the selected value of a drop-down list with jQueryWhat is JSONP, and why was it created?Is Safari on iOS 6 caching $.ajax results?Is it bad practice to have a constructor function return a Promise?Why does javascript ES6 Promises continue execution after a resolve?Handling errors in Promise.allWhy do we need middleware for async flow in Redux?Fetch api, why do I have to use then on the response json(), trying to make sens of promisesPassing another promise to a promise handler

Journal published a paper, ignoring my objections as a referee

Cheap oscilloscope showing 16 MHz square wave

Group riding etiquette

Necessity of tenure for lifetime academic research

What are the in-game differences between WoW Classic and the original 2006 Version

How do I get my neighbour to stop disturbing with loud music?

Fixing a blind bolt hole when the first 2-3 threads are ruined?

Why is there no Disney logo in MCU movies?

What are ways to record who took the pictures if a camera is used by multiple people?

How can a trade secret thief avoid being caught?

What is the following VRP?

LWC: Is it safe to rely on window.location.href to get the page url?

Don't look at what I did there

Rapid change in character

What is a "hashed transaction" in SQL Server Replication terminology?

I was given someone else's visa, stamped in my passport

Ask one verbal question to figure out who is blind and who is mute among three persons

Was a six-engine 747 ever seriously considered by Boeing?

Resources to learn about firearms?

Should a TA point out a professor's mistake while attending their lecture?

Could a complex system of reaction wheels be used to propel a spacecraft?

Storing milk for long periods of time

What is the motivation behind designing a control stick that does not move?

Why do presidential pardons exist in a country having a clear separation of powers?



Why i have make another .then to pull a promiseValue from fetch promise


Why does .json() return a promise?How do you access the matched groups in a JavaScript regular expression?Change the selected value of a drop-down list with jQueryWhat is JSONP, and why was it created?Is Safari on iOS 6 caching $.ajax results?Is it bad practice to have a constructor function return a Promise?Why does javascript ES6 Promises continue execution after a resolve?Handling errors in Promise.allWhy do we need middleware for async flow in Redux?Fetch api, why do I have to use then on the response json(), trying to make sens of promisesPassing another promise to a promise handler






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















enter image description here



Hello. First .then is resolved and have a value response. Why if i log res.text it is just a promise, and when i make another then with the same return , next .then with the same res.text it's a string now??
May someone explain it for me:)?










share|improve this question
























  • short answer is - this is how fetch is specified and implemented - so, the reason you have to "make another .then" is because that's how you use fetch API

    – Jaromanda X
    Mar 27 at 23:22











  • Possible duplicate of Why does .json() return a promise?

    – sideshowbarker
    Mar 28 at 1:14

















-1















enter image description here



Hello. First .then is resolved and have a value response. Why if i log res.text it is just a promise, and when i make another then with the same return , next .then with the same res.text it's a string now??
May someone explain it for me:)?










share|improve this question
























  • short answer is - this is how fetch is specified and implemented - so, the reason you have to "make another .then" is because that's how you use fetch API

    – Jaromanda X
    Mar 27 at 23:22











  • Possible duplicate of Why does .json() return a promise?

    – sideshowbarker
    Mar 28 at 1:14













-1












-1








-1








enter image description here



Hello. First .then is resolved and have a value response. Why if i log res.text it is just a promise, and when i make another then with the same return , next .then with the same res.text it's a string now??
May someone explain it for me:)?










share|improve this question














enter image description here



Hello. First .then is resolved and have a value response. Why if i log res.text it is just a promise, and when i make another then with the same return , next .then with the same res.text it's a string now??
May someone explain it for me:)?







javascript promise fetch






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 23:04









Rafal9626Rafal9626

195 bronze badges




195 bronze badges















  • short answer is - this is how fetch is specified and implemented - so, the reason you have to "make another .then" is because that's how you use fetch API

    – Jaromanda X
    Mar 27 at 23:22











  • Possible duplicate of Why does .json() return a promise?

    – sideshowbarker
    Mar 28 at 1:14

















  • short answer is - this is how fetch is specified and implemented - so, the reason you have to "make another .then" is because that's how you use fetch API

    – Jaromanda X
    Mar 27 at 23:22











  • Possible duplicate of Why does .json() return a promise?

    – sideshowbarker
    Mar 28 at 1:14
















short answer is - this is how fetch is specified and implemented - so, the reason you have to "make another .then" is because that's how you use fetch API

– Jaromanda X
Mar 27 at 23:22





short answer is - this is how fetch is specified and implemented - so, the reason you have to "make another .then" is because that's how you use fetch API

– Jaromanda X
Mar 27 at 23:22













Possible duplicate of Why does .json() return a promise?

– sideshowbarker
Mar 28 at 1:14





Possible duplicate of Why does .json() return a promise?

– sideshowbarker
Mar 28 at 1:14












2 Answers
2






active

oldest

votes


















1















The fetch function returns a Promise that resolves with a Body response.



Paraphrased from Mozilla: Fetch and Mozilla: Body:




The fetch() method... returns a Promise that resolves to the Response to that request, whether it is successful or not... Once a Response is retrieved, there are a number of methods available to define what the body content is and how it should be handled.




If you then navigate to the documentation for Body you can see that it has a number of methods on it. The Body.text() method:




Takes a Response stream and reads it to completion. It returns a promise that resolves with a USVString (text). The response is always decoded using UTF-8.




The behavior you've described is how the fetch API is expected to behave.






share|improve this answer
































    0















    The Fetch API returns a promise which resolves to a Response. The Response itself has a text() method which returns a promise as well. You can use this method to read the Response-Stream as a text. See https://developer.mozilla.org/en-US/docs/Web/API/Response






    share|improve this answer



























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387809%2fwhy-i-have-make-another-then-to-pull-a-promisevalue-from-fetch-promise%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1















      The fetch function returns a Promise that resolves with a Body response.



      Paraphrased from Mozilla: Fetch and Mozilla: Body:




      The fetch() method... returns a Promise that resolves to the Response to that request, whether it is successful or not... Once a Response is retrieved, there are a number of methods available to define what the body content is and how it should be handled.




      If you then navigate to the documentation for Body you can see that it has a number of methods on it. The Body.text() method:




      Takes a Response stream and reads it to completion. It returns a promise that resolves with a USVString (text). The response is always decoded using UTF-8.




      The behavior you've described is how the fetch API is expected to behave.






      share|improve this answer





























        1















        The fetch function returns a Promise that resolves with a Body response.



        Paraphrased from Mozilla: Fetch and Mozilla: Body:




        The fetch() method... returns a Promise that resolves to the Response to that request, whether it is successful or not... Once a Response is retrieved, there are a number of methods available to define what the body content is and how it should be handled.




        If you then navigate to the documentation for Body you can see that it has a number of methods on it. The Body.text() method:




        Takes a Response stream and reads it to completion. It returns a promise that resolves with a USVString (text). The response is always decoded using UTF-8.




        The behavior you've described is how the fetch API is expected to behave.






        share|improve this answer



























          1














          1










          1









          The fetch function returns a Promise that resolves with a Body response.



          Paraphrased from Mozilla: Fetch and Mozilla: Body:




          The fetch() method... returns a Promise that resolves to the Response to that request, whether it is successful or not... Once a Response is retrieved, there are a number of methods available to define what the body content is and how it should be handled.




          If you then navigate to the documentation for Body you can see that it has a number of methods on it. The Body.text() method:




          Takes a Response stream and reads it to completion. It returns a promise that resolves with a USVString (text). The response is always decoded using UTF-8.




          The behavior you've described is how the fetch API is expected to behave.






          share|improve this answer













          The fetch function returns a Promise that resolves with a Body response.



          Paraphrased from Mozilla: Fetch and Mozilla: Body:




          The fetch() method... returns a Promise that resolves to the Response to that request, whether it is successful or not... Once a Response is retrieved, there are a number of methods available to define what the body content is and how it should be handled.




          If you then navigate to the documentation for Body you can see that it has a number of methods on it. The Body.text() method:




          Takes a Response stream and reads it to completion. It returns a promise that resolves with a USVString (text). The response is always decoded using UTF-8.




          The behavior you've described is how the fetch API is expected to behave.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 23:13









          DehliDehli

          5,0895 gold badges23 silver badges41 bronze badges




          5,0895 gold badges23 silver badges41 bronze badges


























              0















              The Fetch API returns a promise which resolves to a Response. The Response itself has a text() method which returns a promise as well. You can use this method to read the Response-Stream as a text. See https://developer.mozilla.org/en-US/docs/Web/API/Response






              share|improve this answer





























                0















                The Fetch API returns a promise which resolves to a Response. The Response itself has a text() method which returns a promise as well. You can use this method to read the Response-Stream as a text. See https://developer.mozilla.org/en-US/docs/Web/API/Response






                share|improve this answer



























                  0














                  0










                  0









                  The Fetch API returns a promise which resolves to a Response. The Response itself has a text() method which returns a promise as well. You can use this method to read the Response-Stream as a text. See https://developer.mozilla.org/en-US/docs/Web/API/Response






                  share|improve this answer













                  The Fetch API returns a promise which resolves to a Response. The Response itself has a text() method which returns a promise as well. You can use this method to read the Response-Stream as a text. See https://developer.mozilla.org/en-US/docs/Web/API/Response







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 27 at 23:13









                  Stefan BlambergStefan Blamberg

                  6724 silver badges21 bronze badges




                  6724 silver badges21 bronze badges






























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387809%2fwhy-i-have-make-another-then-to-pull-a-promisevalue-from-fetch-promise%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript