From 030020e7f28ac33e243febce6a6c0bb7d415344e Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 23 Jul 2022 15:06:17 +0800 Subject: [PATCH] feat(gui-v2): JSONUrlTemplateAdpter --- .../utils/parsers/JSONUrlTemplateAdapter.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 packages/nc-gui-v2/utils/parsers/JSONUrlTemplateAdapter.ts diff --git a/packages/nc-gui-v2/utils/parsers/JSONUrlTemplateAdapter.ts b/packages/nc-gui-v2/utils/parsers/JSONUrlTemplateAdapter.ts new file mode 100644 index 0000000000..a9c87e325b --- /dev/null +++ b/packages/nc-gui-v2/utils/parsers/JSONUrlTemplateAdapter.ts @@ -0,0 +1,21 @@ +import JSONTemplateAdapter from './JSONTemplateAdapter' +const { $api } = useNuxtApp() + +export default class JSONUrlTemplateAdapter extends JSONTemplateAdapter { + url: string + constructor(url: string, parserConfig: Record) { + const name = url.split('/').pop() + super(name, parserConfig) + this.url = url + } + + async init() { + const data = await $api.utils.axiosRequestMake({ + apiMeta: { + url: this.url, + }, + }) + this._jsonData = data + await super.init() + } +}