我是法拉第的新手,正在尝试学习如何为 url 参数传递数组。我的代码如下所示:
require 'faraday'
conn = Faraday.new(:url => 'http://foo.com:8888') do |faraday|
faraday.request :url_encoded
faraday.response :logger
faraday.adapter Faraday.default_adapter
end
response = conn.get '/api/endpoint', { :bar => ['baz', 'qux'] }
response.body
当我调试时,我看到 URL 被编码为:
INFO -- : get http://foo.com:8888/api/endpoint?bar[]=baz&bar[]=qux
而不是http://foo.com:8888/api/endpoint?bar=baz&bar=qux
. []
当我传递参数数组时,如何让法拉第对 URL 进行编码?