Moved connections to user page, began search functionality
This commit is contained in:
@@ -1,4 +1,14 @@
|
||||
import type { PageServerLoad } from '../$types'
|
||||
import ytdl from 'ytdl-core'
|
||||
import { SECRET_INTERNAL_API_KEY } from '$env/static/private'
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch }) => {}
|
||||
export const load: PageServerLoad = async ({ fetch, url, locals }) => {
|
||||
const query = url.searchParams.get('query')
|
||||
if (query) {
|
||||
const searchResults: { searchResults: (Song | Album | Artist | Playlist)[] } = await fetch(`/api/search?query=${query}&userId=${locals.user.id}`, {
|
||||
method: 'GET',
|
||||
headers: { apikey: SECRET_INTERNAL_API_KEY },
|
||||
}).then((response) => response.json())
|
||||
|
||||
return searchResults
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
<h1>Search Page</h1>
|
||||
<script lang="ts">
|
||||
import type { PageServerData } from './$types'
|
||||
|
||||
export let data: PageServerData
|
||||
</script>
|
||||
|
||||
{#if data.searchResults}
|
||||
{#each data.searchResults as searchResult}
|
||||
<div>{searchResult.name} - {searchResult.type}</div>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user