Anonymous user
HTTP: Difference between revisions
→Browser
(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');
</syntaxhighlight>▼
Using fetch API:
<syntaxhighlight lang="javascript">
fetch('http://rosettacode.org').then(function (response) {▼
return response.text();
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:
|