Skip to content

Commit

Permalink
fix: client gets initialized after checking env var value
Browse files Browse the repository at this point in the history
  • Loading branch information
matfire committed Jan 20, 2024
1 parent e92bf7c commit b6f02a1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/routes/api/unsplash/+server.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { env } from '$env/dynamic/private';
import { fail, json, type RequestHandler } from '@sveltejs/kit';
import { createApi } from 'unsplash-js';
const client = createApi({ accessKey: UNSPLASH_TOKEN });

export const GET: RequestHandler = async ({ url }) => {
const { UNSPLASH_TOKEN } = env;
if (!UNSPLASH_TOKEN) {
throw fail(500, { message: 'could not find unsplash configuration' });
}
const client = createApi({ accessKey: UNSPLASH_TOKEN });
const query = url.searchParams.get('query');
const page = url.searchParams.has('page') ? parseInt(url.searchParams.get('page')) : 1;
if (query) {
Expand Down

0 comments on commit b6f02a1

Please sign in to comment.