Open
Description
Describe your feature request here.
Add the Fetch API to PythonMonkey as per its spec (or a subset of it)
- Spec: https://fetch.spec.whatwg.org/
- MDN: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
Work for fetch will include:
fetch
function (https://fetch.spec.whatwg.org/#fetch-method)Request
interfaceResponse
interfaceHeaders
interface- and potentially more - please refer to the spec
This will likely be implemented as a wrapper over Python's requests module.
Using fetch
from JavaScript code would be very familiar for Web developers using PythonMonkey. It will also provide fetch to Python developers as an alternative promise based request api.
Example usage (in Python):
import pythonmonkey
import asyncio
async def logMovies():
response = await pythonmonkey.fetch("http://example.com/movies.json")
movies = await response.json()
print(movies)
asyncio.run(logMovies)
Example usage (in JavaScript):
async function logMovies() {
const response = await fetch("http://example.com/movies.json");
const movies = await response.json();
console.log(movies);
}
logMovies()
Code example
Promise<Response> fetch(RequestInfo input, optional RequestInit init = {});
Metadata
Metadata
Assignees
Type
Projects
Status
Backlog