This commit is contained in:
parent
19b541d51a
commit
acfdc38dd4
4 changed files with 49 additions and 69 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { env } from "$env/dynamic/private";
|
||||
import type { PageServerLoad } from "./$types";
|
||||
import { env } from '$env/dynamic/private';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
type Dates = {
|
||||
createdAt: string;
|
||||
|
|
@ -71,20 +71,19 @@ export const load: PageServerLoad = async () => {
|
|||
const response = await fetch(
|
||||
`http://${env.STRAPI_HOST}:${env.STRAPI_PORT}/api/blogs?populate=Header&populate=Topics`,
|
||||
{
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `bearer ${env.STRAPI_TOKEN}`,
|
||||
},
|
||||
},
|
||||
Authorization: `bearer ${env.STRAPI_TOKEN}`
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const { data, meta }: { data: BlogPost[]; meta: Meta } =
|
||||
await response.json();
|
||||
const { data, meta }: { data: BlogPost[]; meta: Meta } = await response.json();
|
||||
|
||||
console.log(JSON.stringify(data, null, 2));
|
||||
|
||||
return {
|
||||
posts: data,
|
||||
meta,
|
||||
meta
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
import { env } from "$env/dynamic/private";
|
||||
import type { PageServerLoad } from "./$types";
|
||||
import { env } from '$env/dynamic/private';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async ({ params }) => {
|
||||
const { slug } = params;
|
||||
const response = await fetch(
|
||||
`http://${env.STRAPI_HOST}:${env.STRAPI_PORT}/api/blogs/${slug}?populate=Header&populate=Topics`,
|
||||
{
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `bearer ${env.STRAPI_TOKEN}`,
|
||||
},
|
||||
},
|
||||
Authorization: `bearer ${env.STRAPI_TOKEN}`
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const { data, meta } = await response.json();
|
||||
|
|
@ -19,6 +19,6 @@ export const load: PageServerLoad = async ({ params }) => {
|
|||
|
||||
return {
|
||||
post: data,
|
||||
meta,
|
||||
meta
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue