Skip to content

Commit fb96c5f

Browse files
committed
Test working of AbortController in fetch
1 parent 788f0c6 commit fb96c5f

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import FieldAffiliationsTest from './FieldAffiliationsTest.vue';
2+
3+
export default {
4+
title: 'Forms/FieldAffiliationsTest',
5+
};
6+
7+
export const Default = {
8+
component: FieldAffiliationsTest,
9+
render: () => ({
10+
components: {FieldAffiliationsTest},
11+
template: '<FieldAffiliationsTest/>',
12+
}),
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<template>
2+
<div>
3+
<input
4+
v-model="searchPhrase"
5+
class="pkpFormField__input pkpFormField--text__input"
6+
/>
7+
&nbsp;
8+
<button
9+
class="pkpButton pkpFormField__input inline"
10+
@click="executeFetch()"
11+
>
12+
Fetch
13+
</button>
14+
<pre>{{ searchResults }}</pre>
15+
</div>
16+
</template>
17+
18+
<script setup>
19+
import {ref} from 'vue';
20+
import {useFetch} from '@/composables/useFetch';
21+
22+
const searchPhrase = ref('University');
23+
const searchResults = ref();
24+
const url = 'https://api.ror.org/v2/organizations?query=';
25+
26+
async function executeFetch() {
27+
const {data, isSuccess, fetch} = useFetch(url + searchPhrase.value);
28+
await fetch();
29+
if (isSuccess) searchResults.value = data;
30+
}
31+
</script>

0 commit comments

Comments
 (0)