From 7c32ab068d3c745147640e49d02e96224b6dfedf Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 6 Aug 2020 21:31:53 +0900 Subject: [PATCH] =?UTF-8?q?jQuery.ajax=E3=81=AE=E6=9D=91=E3=82=92=E6=BB=85?= =?UTF-8?q?=E3=81=BC=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/checkin.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/resources/assets/js/checkin.ts b/resources/assets/js/checkin.ts index 7902965..4a1bf50 100644 --- a/resources/assets/js/checkin.ts +++ b/resources/assets/js/checkin.ts @@ -1,6 +1,7 @@ import Vue from 'vue'; import TagInput from './components/TagInput.vue'; import MetadataPreview from './components/MetadataPreview.vue'; +import { fetchGet, ResponseError } from './fetch'; export const bus = new Vue({ name: 'EventBus' }); @@ -47,19 +48,18 @@ new Vue({ fetchMetadata(url: string) { this.metadataLoadState = MetadataLoadState.Loading; - $.ajax({ - url: '/api/checkin/card', - method: 'get', - type: 'json', - data: { - url, - }, - }) + fetchGet('/api/checkin/card', { url }) + .then((response) => { + if (!response.ok) { + throw new ResponseError(response); + } + return response.json(); + }) .then((data) => { this.metadata = data; this.metadataLoadState = MetadataLoadState.Success; }) - .catch((_e) => { + .catch(() => { this.metadata = null; this.metadataLoadState = MetadataLoadState.Failed; });