Skip to content Skip to sidebar Skip to footer

Axios And Fetch Both Result In CORS Error But Postman Doesn't

If I make a ajax request using either Axios or Fetch to this public endpoint: http://api.flickr.com/services/feeds/photos_public.gne?format=json I get the following error: Access t

Solution 1:

Its not an issue of postman vs axios or fetch. The issue is the server is returning jsonp not json. Neither Axios nor Fetch support jsonp.

Why not use ajax here?

$(document).ready(function() {
    $.ajax({
        url: 'http://api.flickr.com/services/feeds/photos_public.gne?format=json',
        dataType: 'jsonp',
        jsonpCallback: 'jsonFlickrFeed'
    });
    window.jsonFlickrFeed = function(response) {
    	console.log(response)
    }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Post a Comment for "Axios And Fetch Both Result In CORS Error But Postman Doesn't"