--- title: Response.url slug: Web/API/Response/url translation_of: Web/API/Response/url ---
{{APIRef("Fetch")}}

The url read-only property of the {{domxref("Response")}} interface contains the URL of the response. The value of the url property will be the final URL obtained after any redirects. 

Syntax

var myURL = response.url;

Value

A {{domxref("USVString")}}.

Example

In our Fetch Response example (see Fetch Response live) we create a new {{domxref("Request")}} object using the {{domxref("Request.Request","Request()")}} constructor, passing it a JPG path. We then fetch this request using {{domxref("GlobalFetch.fetch","fetch()")}}, extract a blob from the response using {{domxref("Body.blob")}}, create an object URL out of it using {{domxref("URL.createObjectURL")}}, and display this in an {{htmlelement("img")}}.

Note that at the top of the fetch() block we log the response URL to the console.

var myImage = document.querySelector('img');

var myRequest = new Request('flowers.jpg');

fetch(myRequest).then(function(response) {
  console.log(response.url); // returns https://developer.mozilla.org/en-US/docs/Web/API/Response/flowers.jpg
  response.blob().then(function(myBlob) {
    var objectURL = URL.createObjectURL(myBlob);
    myImage.src = objectURL;
  });
});

Specifications

Specification Status Comment
{{SpecName('Fetch','#dom-response-url','url')}} {{Spec2('Fetch')}} Initial definition

Browser compatibility

{{Compat("api.Response.url")}}

See also