Get request url from xhr object

前端 未结 6 1677
闹比i
闹比i 2020-12-03 04:31

Is there any way to extract the request url from an xhr object? I can see the url in firebug via the channel property but you cant query this using javascript.

6条回答
  •  攒了一身酷
    2020-12-03 05:01

    A couple of related properties that could be useful are:


    xhr2

    XMLHttpRequest.responseURL - https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseURL.

    This is not supported by IE.


    fetch

    If you are using fetch you can use Response.url - https://developer.mozilla.org/en-US/docs/Web/API/Response/url.

    This is not supported by IE.

提交回复
热议问题