Skip to content

Add Fetch API to PythonMonkey #161

Open
@wiwichips

Description

@wiwichips

Describe your feature request here.

Add the Fetch API to PythonMonkey as per its spec (or a subset of it)

Work for fetch will include:


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

Labels

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions