HTTP: Difference between revisions

198 bytes added ,  6 months ago
(Initial FutureBasic task solution added)
imported>Gabrielsroka
Line 1,411:
 
===Browser===
Using fetch API and async/await:
<syntaxhighlight lang="javascript">
const resposne = await fetch('http://rosettacode.org');
const text return= await response.text();
console.log(myTexttext);
</syntaxhighlight>
 
Using fetch API:
<syntaxhighlight lang="javascript">
fetch('http://rosettacode.org').then(function (response) {
return response.text();
}).then(function (myTexttext) {
console.log(text);
});
</syntaxhighlight>
 
<syntaxhighlight lang="javascript">var req = new XMLHttpRequest();
req.onload = function() {
Line 1,418 ⟶ 1,434:
req.open('get', 'http://rosettacode.org', true);
req.send()</syntaxhighlight>
 
Using fetch API:
<syntaxhighlight lang="javascript">
fetch('http://rosettacode.org').then(function(response) {
return response.text();
}).then(function(myText) {
console.log(myText);
});
</syntaxhighlight>
 
As a repeatable function:
Anonymous user