Skip to content

Commit

Permalink
wip: add server proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
azuki774 committed Aug 13, 2024
1 parent d1d0600 commit 90c18f8
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 1 deletion.
26 changes: 25 additions & 1 deletion components/PostRecord.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,43 @@ const asyncData = await useAsyncData(
const response = $fetch(url);
return response;
}
);
);
const data = asyncData.data.value as Category[];
categoryList.value = data
// pricebox
const priceBox = ref<number>()
const postButton = async (): Promise<void> => {
console.log('start')
const asyncData = await useAsyncData(
`record`,
(): Promise<any> => {
const url = "/api/postRecord"
const response = $fetch(url);
console.log('response')
return response;
}
);
};
</script>

<template>
<section>

<select name="categorySelector">
<option v-for="category in categoryList" :key="category.category_id">
{{ category.category_name }}
</option>
</select>

<input v-model="priceBox" type="number" />

<div class="col">
<button @click="postButton" name="postButton" class="sendbutton" type="submit">Post</button>
</div>

</section>
</template>
84 changes: 84 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions server/api/postRecord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default defineEventHandler ( async (event) => {
const config = useRuntimeConfig()
const query = getQuery(event)
const url = "http://172.19.250.172:8080/v2/records" // TODO
const result = await $fetch(url)
return result
})

0 comments on commit 90c18f8

Please sign in to comment.