-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
33 lines (32 loc) · 1021 Bytes
/
utils.js
File metadata and controls
33 lines (32 loc) · 1021 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
export function fetchResource(input, init) {
return new Promise((resolve, reject) => {
chrome.runtime.sendMessage({type: 'fetch', input, init}, messageResponse => {
const [response, error] = messageResponse;
if (response === null) {
reject(error);
} else {
// Use undefined on a 204 - No Content
const body = response.body ? new Blob([response.body]) : undefined;
resolve(new Response(body, {
status: response.status,
statusText: response.statusText,
}));
}
});
});
}
export function getDB() {
return new Promise((resolve, reject) => {
// chrome.tabs.executeScript({file: 'aws-sdk-2.7.16.js'});
// resolve(`AWS=${window.AWS}`)
chrome.runtime.sendMessage({type: 'dynamoDB'}, messageResponse => {
const [response, error] = messageResponse;
if (response === null) {
reject(error);
} else {
// Use undefined on a 204 - No Content
resolve(response)
}
});
});
}