-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test working of AbortController in fetch
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/components/Form/fields/FieldAffiliationsTest.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/>', | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
/> | ||
| ||
<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> |