-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.js
More file actions
33 lines (30 loc) · 711 Bytes
/
fetch.js
File metadata and controls
33 lines (30 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(function(Scratch) {
'use strict';
class Fetch {
getInfo () {
return {
id: 'fetch',
name: 'Fetch',
blocks: [
{
opcode: 'get',
blockType: Scratch.BlockType.REPORTER,
text: 'GET [URL]',
arguments: {
URL: {
type: Scratch.ArgumentType.STRING,
defaultValue: 'https://extensions.turbowarp.org/hello.txt'
}
}
}
]
};
}
get (args) {
return fetch(args.URL)
.then(r => r.text())
.catch(() => '');
}
}
Scratch.extensions.register(new Fetch());
})(Scratch);