Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from js import fetch treats fetch as a free function #461

Closed
madhur-tandon opened this issue Jun 11, 2019 · 0 comments · Fixed by #1126
Closed

from js import fetch treats fetch as a free function #461

madhur-tandon opened this issue Jun 11, 2019 · 0 comments · Fixed by #1126
Assignees

Comments

@madhur-tandon
Copy link
Member

fetch is a member function of window.
However, using from js import fetch doesn't realize that and leads to the error:

TypeError: 'fetch' called on an object that does not implement interface Window.

For Reproducing the Error:

%%py

from js import document, Request, fetch, URL
img_tag = document.createElement('img')
req = Request.new('https://i.ibb.co/3f4yJQS/face4.jpg')

def func(response):
    return response.blob()

def func2(blob):
    objURL = URL.createObjectURL(blob)
    img_tag.src = objURL

fetch(req).then(func).then(func2)

document.body.appendChild(img_tag)
@mdboom mdboom self-assigned this Jun 12, 2019
hoodmane pushed a commit to hoodmane/pyodide that referenced this issue Jan 12, 2021
hoodmane pushed a commit to hoodmane/pyodide that referenced this issue Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants