2

I'm using Faraday to check for broken links, and I want to retrieve the response.URL of the links I'm querying, however, I am not able to find any documentation and examples to do so.

I was able to do this on the front-end using Javascript's Fetch API (Response.url: https://developer.mozilla.org/en-US/docs/Web/API/Response/url) but that is not an option now as I am required to do this on the backend using Faraday only.

Is this even possible with Faraday? If so, how do I implement it? Or kindly point me to the right documentation.

iamleftclick
  • 63
  • 1
  • 9

1 Answers1

4

There are lots of class variables instantiated in the response object: response.env You might be looking at:

response.env.url.to_s
Fernand
  • 1,293
  • 1
  • 10
  • 18
  • Thank you! Just what I need. Though, may I ask, how do I output all the variables/attributes of response.env? Say, I want to check what other variables are there other than response.env.url. I haven't found any guide to do it in the official docs. – iamleftclick Jun 03 '20 at 11:36
  • Great! In order to debug. you can use inspect to see the content of a class. "puts response.inspect" or "puts response.env.inspect" – Fernand Jun 03 '20 at 13:08
  • Awesome! Thanks a lot! – iamleftclick Jun 03 '20 at 22:18