-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added the feature to change the url onclick, onclose is implemented
- Loading branch information
1 parent
9b284a4
commit 1dfdc5a
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { error, json } from '@sveltejs/kit'; | ||
|
||
import { PUBLIC_OBA_SERVER_URL as baseURL } from '$env/static/public'; | ||
import { PRIVATE_OBA_API_KEY as apiKey } from '$env/static/private'; | ||
|
||
/** @type {import('./$types').RequestHandler} */ | ||
export async function GET({ params }) { | ||
const stopID = params.stopID; | ||
const apiURL = `${baseURL}/api/where/stop/${stopID}.json?key=${apiKey}`; | ||
const response = await fetch(apiURL); | ||
|
||
if (!response.ok) { | ||
return error(500, 'Unable to fetch arrivals-and-departures-for-stop.'); | ||
} | ||
|
||
const data = await response.json(); | ||
return json(data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script context="module"> | ||
import StopPane from '../../../components/oba/StopPane.svelte'; | ||
export async function load({ params }) { | ||
const stopID = params.stopID; | ||
const response = await fetch(`/api/oba/stops/${stopID}`); | ||
if (!response.ok) { | ||
return { | ||
status: response.status, | ||
error: new Error('Failed to fetch stop data') | ||
}; | ||
} | ||
const stopData = await response.json(); | ||
return { | ||
props: { | ||
stopData | ||
} | ||
}; | ||
} | ||
</script> | ||
|
||
<script> | ||
export let stopData; | ||
</script> | ||
|
||
<StopPane {stopData} /> |