Skip to content

Instantly share code, notes, and snippets.

@jcuffe
Created April 30, 2022 16:30
Show Gist options
  • Save jcuffe/a1d0e8fe70d15eb21501aa41b5ab3ef8 to your computer and use it in GitHub Desktop.
Save jcuffe/a1d0e8fe70d15eb21501aa41b5ab3ef8 to your computer and use it in GitHub Desktop.
Invocation context example
import { useStore, component$ } from '@builder.io/qwik';
import axios from 'axios';
export const Main = component$(async () => {
const response = await axios.get('https://httpbin.org/')
const state = useStore({ name: 'World', status: response.status });
return (
<p>Status: {state.status}</p>
);
});
import { useStore, component$ } from '@builder.io/qwik';
import axios from 'axios';
export const Main = component$(async () => {
const state = useStore({ name: 'World', status: undefined });
state.status = (await axios.get('https://httpbin.org/')).status;
return (
<p>Status: {state.status}</p>
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment