Skip to content

Commit

Permalink
Test working of AbortController in fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
GaziYucel committed Jan 9, 2025
1 parent 788f0c6 commit fb96c5f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/Form/fields/FieldAffiliationsTest.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import FieldAffiliationsTest from './FieldAffiliationsTest.vue';

export default {
title: 'Forms/FieldAffiliationsTest',
};

export const Default = {
component: FieldAffiliationsTest,
render: () => ({
components: {FieldAffiliationsTest},
template: '<FieldAffiliationsTest/>',
}),
};
31 changes: 31 additions & 0 deletions src/components/Form/fields/FieldAffiliationsTest.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<div>
<input
v-model="searchPhrase"
class="pkpFormField__input pkpFormField--text__input"
/>
&nbsp;
<button
class="pkpButton pkpFormField__input inline"
@click="executeFetch()"
>
Fetch
</button>
<pre>{{ searchResults }}</pre>
</div>
</template>

<script setup>
import {ref} from 'vue';
import {useFetch} from '@/composables/useFetch';
const searchPhrase = ref('University');
const searchResults = ref();
const url = 'https://api.ror.org/v2/organizations?query=';
async function executeFetch() {
const {data, isSuccess, fetch} = useFetch(url + searchPhrase.value);
await fetch();
if (isSuccess) searchResults.value = data;
}
</script>

0 comments on commit fb96c5f

Please sign in to comment.