Response.vue 862 B

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <AppSection label="response">
  3. <HttpResponseMeta :response="response" />
  4. <LensesResponseBodyRenderer
  5. v-if="!loading && hasResponse"
  6. :response="response"
  7. />
  8. </AppSection>
  9. </template>
  10. <script lang="ts">
  11. import { computed, defineComponent } from "@nuxtjs/composition-api"
  12. import { useReadonlyStream } from "~/helpers/utils/composables"
  13. import { restResponse$ } from "~/newstore/RESTSession"
  14. export default defineComponent({
  15. setup() {
  16. const response = useReadonlyStream(restResponse$, null)
  17. const hasResponse = computed(
  18. () =>
  19. response.value?.type === "success" || response.value?.type === "fail"
  20. )
  21. const loading = computed(
  22. () => response.value === null || response.value.type === "loading"
  23. )
  24. return {
  25. hasResponse,
  26. response,
  27. loading,
  28. }
  29. },
  30. })
  31. </script>