-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathfetch.js
More file actions
27 lines (23 loc) · 983 Bytes
/
fetch.js
File metadata and controls
27 lines (23 loc) · 983 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
import Route from '@ember/routing/route';
import { assert } from '@ember/debug';
export default class FetchRoute extends Route {
beforeModel() {
assert('fetch is available', fetch);
assert('Request is available', Request);
assert('Response is available', Response);
assert('Headers is available', Headers);
assert('AbortController is available', AbortController);
}
async model() {
let responses = await Promise.all([
fetch('http://localhost:45678/absolute-url.json'),
fetch(new Request('http://localhost:45678/absolute-request.json')),
fetch('//localhost:45678/protocol-relative-url.json'),
fetch(new Request('//localhost:45678/protocol-relative-request.json')),
fetch('/path-relative-url.json'),
fetch(new Request('/path-relative-request.json')),
]);
responses = await Promise.all(responses.map((response) => response.json()));
return responses.map((response) => response.response).join('|');
}
}