w-aura/src/api/resources/Element.ts
Aidar Shaikhutdin @makeweb.space 944d7210f7 feat: add static pages
2023-05-21 09:15:10 +06:00

32 lines
613 B
TypeScript

import routes from '../../routes'
import { getBaseHeaders } from '../utils'
export interface Payload {
locale: string
type: string
}
export interface Response {
data: {
variant: string
element: Element
}
}
export interface Element {
type: string
href: string
title: string
url_slug: string
body: string
}
export const createRequest = ({ locale, type }: Payload): Request => {
const url = new URL(routes.server.element(type))
const query = new URLSearchParams({ locale })
url.search = query.toString()
return new Request(url, { method: 'GET', headers: getBaseHeaders() })
}