Changed deploy to node server
Afaik, Nanostores need SSR in the setup I used, so for now, the build will have to be deployed on a node server. I could have used a full Vue app to avoid this, but oh well, nothing we can't refactor ; and it just works anyways. Plus it would have meant switching to a vue leaflet wrapper that hasn't been maintained in years. Can always change it later.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { deepMap, onMount, task, action } from 'nanostores'
|
||||
import type { MapCoords, MapMarker } from '../../types/Leaflet';
|
||||
import { deepMap, onMount, task } from 'nanostores'
|
||||
import type { MapMarker } from '../../types/Leaflet';
|
||||
|
||||
export const $world = deepMap({
|
||||
markers: [] as MapMarker[],
|
||||
@@ -10,12 +10,24 @@ export const $world = deepMap({
|
||||
onMount($world, () => {
|
||||
// Fetch all markers
|
||||
task(async () => {
|
||||
const m = await fetch('http://localhost:4321/api/markers.json')
|
||||
$world.setKey('markers', await m.json())
|
||||
let m
|
||||
try {
|
||||
m = await fetch('http://localhost:4321/api/markers.json')
|
||||
|
||||
$world.setKey('markers', await m.json())
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
// Fetch all player data
|
||||
task(async () => {
|
||||
const p = await fetch('http://localhost:4321/api/players.json')
|
||||
$world.setKey('players', await p.json())
|
||||
let p
|
||||
try {
|
||||
p = await fetch('http://localhost:4321/api/players.json')
|
||||
|
||||
$world.setKey('players', await p.json())
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user