Conditions | 1 |
Total Lines | 20 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | // Class imports |
||
9 | /** |
||
10 | * The method responsible for fetching the remote data |
||
11 | * @returns Promise Returns a promise with the data fetched. Implements a catch that hides elements and shows error message if there is an error |
||
12 | */ |
||
13 | static fetchRemoteData() { |
||
14 | const bilInformasjon = (<HTMLInputElement>( |
||
15 | window.document.getElementById('bilinformasjon') |
||
16 | )).value; |
||
17 | const regNummer = `${process.env.API_URL}${bilInformasjon}`; |
||
18 | |||
19 | return fetch(regNummer) |
||
20 | .then(async (response) => { |
||
21 | const bilResponse = await response.text(); |
||
22 | const bilData = JSON.parse(bilResponse); |
||
23 | return bilData; |
||
24 | }) |
||
25 | .catch(function (error) { |
||
26 | // Hide elements if we have an error |
||
27 | classShowHideElements.hideElements(); |
||
28 | classErrorHandler.showErrorFetchingRegNr(); |
||
29 | }); |
||
32 |