how can I get response of cross site request - javascript

I made a cross site request and the server is not in my control,.
So how can I get the response value?
I can see the response json value in the console of Firefox as shown below :

Related

Is it possible to get request headers from one request and send them to another in web console?

When I open the 'Network' tab in my web console of a post request which has both response and request headers, in the 'Request Headers' part there is some data send. Is it possible to 'copy' this data and re-send them to another url using fetch with post method?

How To Call Medium RSS Feed

Medium has an RSS feed available at https://medium.com/feed/[#username]. I'm trying to fetch all my blog posts using an XMLHTTPRequest. When I test on local, I run into CORs errors. When I turn on CORs Chrome extension, I get a 401 error. Any ideas? Has anyone succeeded in calling Medium RSS?
To get https://medium.com/feed/[#username] content using XHR, you can make the XHR request through a proxy of some kind. For example, trying giving your current XHR code this URL:
https://cors-anywhere.herokuapp.com/https://medium.com/feed/#sideshowbarker
That’ll cause the request to go to https://cors-anywhere.herokuapp.com, a open/public CORS proxy which then sends the request on to https://medium.com/feed/#sideshowbarker.
And when that proxy gets the response, it takes it and adds the Access-Control-Allow-Origin response header to it and then passes that back to your requesting frontend code as the response.
That response with the Access-Control-Allow-Origin response header is what the browser sees, so the error message the browser is showing you now goes away, and the browser allows your frontend JavaScript code to access the response.
Or use the code from https://github.com/Rob--W/cors-anywhere/ or such to set up your own proxy.
The reason you need a proxy is, responses from https://medium.com/feed/[#username] don’t include the Access-Control-Allow-Origin response header, so your browser will refuse to let your frontend JavaScript code access those responses cross-origin.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS has more details.
This is a bug.
Bug has opened. (Dan Abramov approved)

Are HTTP headers handled automatically by the browser in AJAX responses?

Here's my situation: I make an ajax post to a server endpoint, and it sends me back some JSON data in response. This JSON response also includes the Set-cookie header.
Does the cookie get set automatically when it's in a response to an ajax request, or do I have to read it out of the headers and do it manually?
(As opposed to the headers being present on the response to a form submit, where I know the browser will be handling the response and its headers on its own, no JS necessarily involved.)
Yes, it gets set automatically. An AJAX request is just an HTTP request. You can send Cookie headers, and receive Set-Cookie Headers normally.

XHR request shows canceled status in Chrome (not CORS)

I make an XHR Post request in Chrome and it immediately returns with an response with a type of error with no detail info. In Chrome the response status shows up as "canceled". However the request actually reaches the server and is processed by the server (verified with a breakpoint). But the XHR error response and Chrome response status of "canceled" occurs before the request reaches the server. I'm testing using a local webserver and app server with a single origin of "local.mydomain.com". So there is no cross-domain implications. What could be causing this behavior?

Cookie received in response but not getting saved

I'm receiving a Set-Cookie header in response as shown in this image:
But it is not being set i.e. it is not visible in Resource -> Cookies in Chrome. What can I do about it or is it a problem with the API?

Categories