summaryrefslogtreecommitdiff
path: root/client/src/functions.js
blob: a43dbac2bb68ab50f67f69101e6774a9a38f0b5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// client/src/function.js
export async function fetchAttractions() {

    try {

        const response = await fetch("api/attractions");

        if (!response.ok) {
            const message = `An error has occured: ${response.status}`;
            throw new Error(message);
        }

        const attractions = await response.json();
        return attractions;


    } catch(error) {
        console.log("something went wrong when fetching attractions: ", error);
    }

}