diff options
Diffstat (limited to 'client/src/functions.js')
| -rw-r--r-- | client/src/functions.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/client/src/functions.js b/client/src/functions.js new file mode 100644 index 0000000..7f06c3b --- /dev/null +++ b/client/src/functions.js @@ -0,0 +1,20 @@ +// Dynamic article displaying +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 = response.json(); + return attractions; + + } catch(error) { + console.log("something went wrong when fetching attractions: ", error); + } + +} |
