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

How to do a no-cors request to flickr open api? #280

Closed
morgs32 opened this issue Feb 17, 2016 · 4 comments
Closed

How to do a no-cors request to flickr open api? #280

morgs32 opened this issue Feb 17, 2016 · 4 comments

Comments

@morgs32
Copy link

morgs32 commented Feb 17, 2016

This is more of a question than an issue. A question to you but an issue to me. I'm trying to use fetch to hit the flicker open api, or to make cross origin requests in general, and can't. I've gathered that I should use mode: 'no-cors' but that results in an "opaque" response, which doesn't provide me the json data I need.

Even though I can see in the network tab that the JSON was sent back with the response, in fact.

Any help would be a big help!?

Here's a codepen. The request works with jquery. Not with fetch.
http://codepen.io/morgs32/pen/OMGEpm

@dgraham
Copy link
Contributor

dgraham commented Feb 17, 2016

Flickr does not support CORS headers on api.flickr.com, so fetch and XMLHttpRequest will not work.

jQuery is sending a JSONP request and evaluating the JavaScript served in Flickr's response with an injected <script> element.

@dgraham dgraham closed this as completed Feb 17, 2016
@vabruzzo
Copy link

The issue claims that the fetch is unsuccessful in general. I have tried to do a simple fetch of github.com, as the example demonstrates, and I have been unsuccessful. Is there some trick not included in the example code?

@dgraham
Copy link
Contributor

dgraham commented Feb 18, 2016

Cross-origin resource sharing requires the participation of the server via the Access-Control-Allow-Origin response header. We don't serve that header from the github.com domain, but we do support CORS from api.github.com.

Compare the results of the following requests:

fetch('https://github.com')
fetch('https://api.github.com')

@vabruzzo
Copy link

Thanks, I thought this might be the case, but since the example uses github.com. rather than api.giuthub.com, I thought it might be the case that it was supposed to work. I'll put in a pr to change the example.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants