jQuery.ajaxの村を滅ぼした
This commit is contained in:
parent
3a1ec763ea
commit
7c32ab068d
@ -1,6 +1,7 @@
|
|||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import TagInput from './components/TagInput.vue';
|
import TagInput from './components/TagInput.vue';
|
||||||
import MetadataPreview from './components/MetadataPreview.vue';
|
import MetadataPreview from './components/MetadataPreview.vue';
|
||||||
|
import { fetchGet, ResponseError } from './fetch';
|
||||||
|
|
||||||
export const bus = new Vue({ name: 'EventBus' });
|
export const bus = new Vue({ name: 'EventBus' });
|
||||||
|
|
||||||
@ -47,19 +48,18 @@ new Vue({
|
|||||||
fetchMetadata(url: string) {
|
fetchMetadata(url: string) {
|
||||||
this.metadataLoadState = MetadataLoadState.Loading;
|
this.metadataLoadState = MetadataLoadState.Loading;
|
||||||
|
|
||||||
$.ajax({
|
fetchGet('/api/checkin/card', { url })
|
||||||
url: '/api/checkin/card',
|
.then((response) => {
|
||||||
method: 'get',
|
if (!response.ok) {
|
||||||
type: 'json',
|
throw new ResponseError(response);
|
||||||
data: {
|
}
|
||||||
url,
|
return response.json();
|
||||||
},
|
})
|
||||||
})
|
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
this.metadata = data;
|
this.metadata = data;
|
||||||
this.metadataLoadState = MetadataLoadState.Success;
|
this.metadataLoadState = MetadataLoadState.Success;
|
||||||
})
|
})
|
||||||
.catch((_e) => {
|
.catch(() => {
|
||||||
this.metadata = null;
|
this.metadata = null;
|
||||||
this.metadataLoadState = MetadataLoadState.Failed;
|
this.metadataLoadState = MetadataLoadState.Failed;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user