2022-04-20 02:15:46 +00:00
|
|
|
import type { RequestHandler } from '@sveltejs/kit';
|
|
|
|
|
import { boardGameApi } from '../_api';
|
|
|
|
|
|
2022-07-19 21:04:32 +00:00
|
|
|
export const GET: RequestHandler = async ({ params }) => {
|
2022-07-11 04:17:59 +00:00
|
|
|
// console.log('params', params);
|
|
|
|
|
const queryParams = {
|
2022-07-28 00:05:54 +00:00
|
|
|
ids: `${params?.id}`
|
|
|
|
|
};
|
2022-07-11 04:17:59 +00:00
|
|
|
console.log('queryParams', queryParams);
|
|
|
|
|
const response = await boardGameApi('get', `search`, queryParams);
|
|
|
|
|
if (response.status === 404) {
|
|
|
|
|
return {
|
|
|
|
|
body: {
|
|
|
|
|
games: []
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2022-04-20 02:15:46 +00:00
|
|
|
|
2022-07-11 04:17:59 +00:00
|
|
|
if (response.status === 200) {
|
|
|
|
|
const gameResponse = await response.json();
|
|
|
|
|
// console.log('gameResponse', gameResponse);
|
|
|
|
|
// const games = gameResponse?.games;
|
|
|
|
|
console.log('game', gameResponse?.games[0]);
|
|
|
|
|
return {
|
|
|
|
|
body: {
|
2022-07-28 00:05:54 +00:00
|
|
|
game: gameResponse?.games[0]
|
2022-07-11 04:17:59 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2022-04-20 02:15:46 +00:00
|
|
|
|
2022-07-11 04:17:59 +00:00
|
|
|
return {
|
|
|
|
|
status: response.status
|
|
|
|
|
};
|
2022-07-28 00:05:54 +00:00
|
|
|
};
|