fetch-for-osascript.js(файл создан)
@@ -0,0 +1,16 @@ | |||
1 | + | /* | |
2 | + | Try it from the command line on Mac: | |
3 | + | `osascript -l JavaScript fetch-for-osascript.js` | |
4 | + | */ | |
5 | + | function fetch(url) { | |
6 | + | const queryURL = $.NSURL.URLWithString(url); | |
7 | + | const requestData = $.NSData.dataWithContentsOfURL(queryURL); | |
8 | + | const requestString = $.NSString.alloc.initWithDataEncoding( | |
9 | + | requestData, | |
10 | + | $.NSUTF8StringEncoding, | |
11 | + | ).js; | |
12 | + | return JSON.parse(requestString); | |
13 | + | } | |
14 | + | ||
15 | + | const json = fetch("https://melaniekat.com/gifs/api") | |
16 | + | console.log(JSON.stringify(json)) |
Новее
Позже