acdh-oeaw / mmp-frontend

Mapping Medieval Peoples (MMP) frontend
https://mmp.acdh.oeaw.ac.at
MIT License
0 stars 0 forks source link

feat: add client for mmp api #113

Closed stefanprobst closed 1 year ago

stefanprobst commented 1 year ago

this adds a typed api client for the mmp rest api with request deduplication and response caching.

use like this:

<script lang="ts" setup>
import { useAuthors } from '@/api'

const { data, status, error } = useAuthors()
</script>

when passing params, make sure to pass a ref if the query should update when params change:

<script lang="ts" setup>
import { ref } from 'vue';

import type { GetAuthors } from '@/api';
import { useAuthors } from '@/api';

const searchParams = ref<GetAuthors.SearchParams>({ name: 'stefan' });

const { data, status, error } = useAuthors(searchParams);
</script>