Jump to content

Copy API response to clipboard


Recommended Posts

Posted

Trying to create a little workflow as practice. Querying an API, parsing the response, and then (trying to) copying the result to my clipboard.

 

Here's my script:

 

require 'json'
require 'uri'
require 'net/http'

uri = URI("https://baconipsum.com/api/?type=all-meat&start-with-lorem=1&paras=5")
res = Net::HTTP.get_response(uri)

value = ""

JSON.parse(res.body).each do |i|
	value += i + " "
end

puts({ items: [value] }.to_json)

 

I get the data back just fine, and it's being returned as an appropriate json hash, but the Alfred window will just sit open and not accept me hitting Enter to copy it to my clipboard.

 

image.thumb.png.efb607d7829e790e6c0239cbaf46b8e3.png

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...