Jump to content

Copy API response to clipboard

Recommended Posts

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 + " "

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.



Link to comment

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...