File tree Expand file tree Collapse file tree 4 files changed +30
-9
lines changed Expand file tree Collapse file tree 4 files changed +30
-9
lines changed Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
- const runs = ref ([]);
3
- const error = ref (null );
2
+ interface Run {
3
+ url: string ;
4
+ status: number ;
5
+ cacheHeaders: Record <string , string >;
6
+ durationInMs: number ;
7
+ }
8
+
9
+ const runs = ref <Run []>([]);
10
+ const error = ref <string | null >(null );
4
11
5
- const handleRequestFormSubmit = async ({ url }): void => {
12
+ const handleRequestFormSubmit = async ({
13
+ url ,
14
+ }: {
15
+ url: string ;
16
+ }): Promise <void > => {
6
17
try {
7
18
// Destructuring would be confusing, since the response body contains fields named `status` and
8
19
// `headers` (it's a request about a request...)
@@ -18,7 +29,9 @@ const handleRequestFormSubmit = async ({ url }): void => {
18
29
});
19
30
20
31
error .value = null ;
21
- } catch (err ) {
32
+ // TODO(serhalp) nuxt doesn't appear to re-export the `FetchError` types from ofetch. Look into
33
+ // this.
34
+ } catch (err : any ) {
22
35
error .value =
23
36
err ?.data ?.message ??
24
37
err ?.toString ?.() ??
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ const cacheAnalysis = computed(() =>
30
30
getCacheAnalysis (props .cacheHeaders , now .value ),
31
31
);
32
32
33
- let timerId;
33
+ let timerId: NodeJS . Timeout | null = null ;
34
34
35
35
onMounted (() => {
36
36
timerId = setInterval (() => {
Original file line number Diff line number Diff line change @@ -3,18 +3,19 @@ const props = defineProps<{
3
3
cacheHeaders: Record <string , string >;
4
4
}>();
5
5
6
- const id = useId ();
7
- const el = useTemplateRef (id );
6
+ const el = useTemplateRef (" code-block" );
8
7
const highlightJson = () => {
9
- hljs .highlightElement (el .value );
8
+ if (el .value != null ) {
9
+ hljs .highlightElement (el .value );
10
+ }
10
11
};
11
12
onMounted (highlightJson );
12
13
onUpdated (highlightJson );
13
14
</script >
14
15
15
16
<template >
16
17
<pre >
17
- <code : ref =" id " class =" hljs language-json" >{{ JSON.stringify(props.cacheHeaders, null, 2) }}</code >
18
+ <code ref =" code-block " class =" hljs language-json" >{{ JSON.stringify(props.cacheHeaders, null, 2) }}</code >
18
19
</pre >
19
20
</template >
20
21
Original file line number Diff line number Diff line change
1
+ declare global {
2
+ const hljs : {
3
+ highlightElement : ( element : HTMLElement ) => void ;
4
+ } ;
5
+ }
6
+
7
+ export { } ;
You can’t perform that action at this time.
0 commit comments