sf-698 / App.js
Rebel Artimus
Add 3 files
6e29150
raw
history blame contribute delete
459 Bytes
import { ref, watch } from 'vue@next';
export default {
setup() {
const hasLoaded = ref(false);
const books = ref([]);
watch(hasLoaded, (value) => {
if (value) {
fetchBooks();
}
});
const fetchBooks = async () => {
const response = await fetch('https://localhost:3000/books');
const data = await response.json();
books.value = data;
};
return {
hasLoaded,
books,
};
},
};