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;
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
add a comment |
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
short answer is - this is howfetch
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
add a comment |
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
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
javascript promise fetch
asked Mar 27 at 23:04
Rafal9626Rafal9626
195 bronze badges
195 bronze badges
short answer is - this is howfetch
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
add a comment |
short answer is - this is howfetch
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
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 27 at 23:13
DehliDehli
5,0895 gold badges23 silver badges41 bronze badges
5,0895 gold badges23 silver badges41 bronze badges
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Mar 27 at 23:13
Stefan BlambergStefan Blamberg
6724 silver badges21 bronze badges
6724 silver badges21 bronze badges
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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