'python's urllib.urlopen for javascript
Is there a module written in javascript that's equivalent to python's urllib? In particular, I want something like:
urllib.urlopen(url, data)
which returns an object that supports a blocking fetch. Alternatively, in what other ways could I perform a blocking request to a server using javascript?
Solution 1:[1]
You can use the normal XMLHttpRequest synchronously:
var xhr = new XMLHttpRequest();
xhr.open('POST', url, false); # third param is sync/async
xhr.send(data);
var response = xhr.responseText;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Daniel Roseman |
