-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.js
40 lines (36 loc) · 1.01 KB
/
util.js
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
34
35
36
37
38
39
40
import { NORWICH_API } from './constants';
export const getAutoCompleteList = (url) => {
return fetch(url)
.then((response) => response.json())
.then((responseJson) => {
return responseJson.predictions;
})
.catch((error) => {
console.error(error);
});
};
export const getDateTime = (datetime) => {
const dateTime = datetime ? datetime.toISOString().split('T') : new Date().toISOString().split('T');
dateTime[1] = dateTime[1].substring(0, 5);
return dateTime;
};
export const getLatLng = (address) => {
const url = NORWICH_API + '/geocode/' + address;
return fetch(url)
.then(response => response.json())
.then(responseJson => { return responseJson; })
.catch((error) => {
console.error(error);
});
};
export const getFromAPI = (url) => {
return fetch(url)
.then((response) => response.json())
.then((responseJson) => {
return responseJson;
})
.catch((error) => {
// create warning service is down
console.error(error);
});
};