Last active
August 29, 2015 14:02
-
-
Save perifer/fde4f6827e4e9417a9c9 to your computer and use it in GitHub Desktop.
Asynchronous Javascript Action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adopted from | |
// http://www.obdev.at/resources/launchbar/developer-documentation/javascript-http.html#//apple_ref/cpp/Method/getJSON | |
function run(done) { | |
var search = 'perfect circle'; | |
var query = encodeURIComponent(search); | |
var result = HTTP.getJSON('http://ws.spotify.com/search/1/artist.json?q=' + query, function(result) { | |
if (result.data != undefined) { | |
// Show the top result: | |
var artist = result.data.artists[0]; | |
done([{ 'title' : artist.name}]); | |
} else if (result.error != undefined) { | |
LaunchBar.alert('Unable to load results for "' + search + '"', result.error); | |
done(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment