From 52595dd3513aa1690815b18a7b714fa0369d53d7 Mon Sep 17 00:00:00 2001 From: Simon Erslev Milfred Date: Tue, 7 Nov 2023 16:04:46 +0100 Subject: [PATCH] fix: slight alteration of mockup --- .playground/app.vue | 2 +- components/FetchForm.vue | 19 +++++++++++-------- package.json | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.playground/app.vue b/.playground/app.vue index d3b4b2e..430d9d9 100644 --- a/.playground/app.vue +++ b/.playground/app.vue @@ -3,7 +3,7 @@ diff --git a/components/FetchForm.vue b/components/FetchForm.vue index 3b02226..2b1f49d 100644 --- a/components/FetchForm.vue +++ b/components/FetchForm.vue @@ -125,14 +125,17 @@ function onSubmit(e) { // Get mockup response if (props.mockupResponse) { const data = typeof props.mockupResponse === 'function' ? props.mockupResponse?.(payload) : props.mockupResponse; - emit('fetch', null); - emit('response', data); - emit('response:full', { data }); - emit('complete', true); - - currentResponse.value = props.mockupResponse; - currentError.value = null; - isFetching.value = false; + emit('fetch', new Promise((resolve) => { + emit('response', data); + emit('response:full', { meta: { code: 200 }, data, error: null }); + emit('complete', true); + + resolve({ meta: { code: 200 }, data, error: null }); + + currentResponse.value = props.mockupResponse; + currentError.value = null; + isFetching.value = false; + })); return; } diff --git a/package.json b/package.json index d912c19..fe40b08 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@limbo-works/fetch-form", "type": "module", - "version": "0.1.0", + "version": "0.1.1", "main": "./nuxt.config.js", "scripts": { "dev": "nuxi dev .playground",