@authentication_cookie = response.env[:response_headers]["set-cookie"]
This line finds the header “set-cookie” in the response and sets it to the instance variable.
Then, I wrote this
response = conn.get do |req| req.headers['cookie'] = authentication_cookie req.url endpoint, params end return response.body
This code makes another request from the same connection established earlier and sets the header cookies to authentication cookie. It then tells the connection to use a specific endpoint (using the API, based on what information you would like) and adds some parameters. This sets the response to whatever is returned from the api and then
response.bodytakes that response and prints out the content of the response but without the headers or other junk we don’t really want to see.