Skip to content

Commit

Permalink
Merge pull request #286 from napcs/master
Browse files Browse the repository at this point in the history
Update client to send JSON in the body
  • Loading branch information
seth-reeser authored Mar 11, 2020
2 parents 3d72277 + 24d1dac commit b4bc3c3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/vagrant-digitalocean/helpers/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ def delete(path, params = {}, method = :delete)
end

def post(path, params = {}, method = :post)
@client.headers['Content-Type'] = 'application/json'
request(path, params, :post)
request(path, {}, :post) do |req|
req.body = params.to_json
req.headers['Content-Type'] = 'application/json'
end
end

def request(path, params = {}, method = :get)
Expand All @@ -41,6 +43,7 @@ def request(path, params = {}, method = :get)
result = @client.send(method) do |req|
req.url path, params
req.headers['Authorization'] = "Bearer #{@config.token}"
yield req if block_given?
end
rescue Faraday::Error::ConnectionFailed => e
# TODO this is suspect but because farady wraps the exception
Expand Down

0 comments on commit b4bc3c3

Please sign in to comment.