Merge pull request #493 from shikorism/fix/491-fetch-card-error

カード情報の取得に失敗した時にちゃんと処理を中断させる
This commit is contained in:
shibafu 2020-08-23 15:18:40 +09:00 committed by GitHub
commit 7cf1a362ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { fetchGet } from './fetch';
import { fetchGet, ResponseError } from './fetch';
export function suicide<T>(e: T) {
return function (): never {
@ -15,7 +15,12 @@ export function linkCard(el: Element) {
}
fetchGet('/api/checkin/card', { url })
.then((response) => response.json())
.then((response) => {
if (response.ok) {
return response.json();
}
throw new ResponseError(response);
})
.then((data) => {
const metaColumn = el.querySelector('.col-12:last-of-type') || die();
const imageColumn = el.querySelector<HTMLElement>('.col-12:first-of-type') || die();