/* Try it from the command line on Mac: `osascript -l JavaScript fetch-for-osascript.js` */ function fetch(url) { const queryURL = $.NSURL.URLWithString(url); const requestData = $.NSData.dataWithContentsOfURL(queryURL); const requestString = $.NSString.alloc.initWithDataEncoding( requestData, $.NSUTF8StringEncoding, ).js; return JSON.parse(requestString); } const json = fetch("https://melaniekat.com/gifs/api") console.log(JSON.stringify(json))