Skip to content

Instantly share code, notes, and snippets.

@mikekellyio
Created September 14, 2015 22:17
Show Gist options
  • Save mikekellyio/70705d4812a448427a3f to your computer and use it in GitHub Desktop.
Save mikekellyio/70705d4812a448427a3f to your computer and use it in GitHub Desktop.
require 'bundler/inline'
# true to install gems
gemfile false do
source 'https://rubygems.org'
gem 'faraday'
gem 'faraday_middleware'
end
conn = Faraday.new(:url => 'http://swapi.co/') do |faraday|
faraday.request :url_encoded # form-encode POST params
faraday.response :logger # log requests to STDOUT
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
faraday.request :json
faraday.response :json, :content_type => /\bjson$/
end
response = conn.get 'api/people/1/'
puts response.body["films"][0]
puts conn.get(response.body["films"][0]).body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment