AtoraSuunva / booru

Searches boorus for images using some js magic
https://www.npmjs.com/package/booru
MIT License
78 stars 19 forks source link

BooruError: Failed to execute 'fetch' on 'Window': Illegal invocation #51

Closed AkashAryal closed 4 years ago

AkashAryal commented 4 years ago

Not sure if this is an issue on my end, but I get the above error when running

export const getLinks = (): AppThunk => dispatch => { 

  Booru.search('safebooru', ['glaceon'], { limit: 3, random: true })
    .then((posts: BooruPost[]) => {
      let arr = posts.map((p: BooruPost) => {
        return p.fileUrl;
      });
      dispatch(populate(arr));
    }).catch((err: any) => {
      console.error("whomp whomp  " + err)
    });

};

Also, I'm using this in a react, redux web app if that is relevant.

AtoraSuunva commented 4 years ago

Seems to be a duplicate of #35

Can you try the latest dev version (npm i booru@dev) and telling me if that fixes it? I don't have a setup able to reproduce this error.

AkashAryal commented 4 years ago

Now i get image

AtoraSuunva commented 4 years ago

That's an issue with safebooru missing CORS headers.

Unfortunately there's nothing I can do in this package to resolve this, either safebooru needs to add a Access-Control-Allow-Origin header to their API or you need to find a way to get around the CORS restriction.