# Server Routes ของ Nuxt (Vue.js / Nuxt.js) > API routes, server middleware, event handlers, H3, request/response, การจัดการข้อผิดพลาด, การตรวจสอบความถูกต้อง - 20 คำถามสัมภาษณ์ - Mid-Level - [คำถามสัมภาษณ์: Vue.js / Nuxt.js](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions.md) ## 1. ควรสร้างไฟล์ในไดเรกทอรีใดเพื่อเปิดให้เข้าถึง API route ที่ /api/users? **คำตอบ** API route ใน Nuxt ถูกสร้างในไดเรกทอรี server/api/ ทุกไฟล์ที่ export event handler จะเข้าถึงได้โดยอัตโนมัติผ่าน /api/ ตามด้วยชื่อไฟล์ ข้อกำหนดนี้ช่วยจัดโครงสร้าง endpoint ฝั่ง backend ได้อย่างชัดเจน พร้อมทั้งได้ประโยชน์จาก hot-reload และ type-safety ของ Nuxt ## 2. ควรใช้ฟังก์ชันใดในการกำหนด event handler ใน API route ของ Nuxt? **คำตอบ** ฟังก์ชัน defineEventHandler เป็น API หลักสำหรับสร้าง route handler ใน Nuxt โดยจะให้ event context ที่มีการกำหนดชนิดข้อมูล ซึ่งช่วยให้เข้าถึงยูทิลิตี H3 สำหรับจัดการ request และ response ฟังก์ชันนี้มาแทนที่ API eventHandler รุ่นเก่า และให้การผสานรวมกับระบบชนิดข้อมูลของ Nuxt ได้ดียิ่งขึ้น ## 3. H3 คืออะไรในบริบทของ server routes ของ Nuxt? **คำตอบ** H3 คือ HTTP framework แบบมินิมอลที่ขับเคลื่อนเอนจินฝั่งเซิร์ฟเวอร์ของ Nuxt โดยมีชุดยูทิลิตีสำหรับจัดการ request และ response แบบ HTTP ได้อย่างมีประสิทธิภาพและปลอดภัยด้านชนิดข้อมูล H3 ถูกออกแบบมาให้มีน้ำหนักเบา รวดเร็ว และเข้ากันได้กับสภาพแวดล้อมรันไทม์ต่าง ๆ เช่น Node.js, Workers และ Deno ## มีอีก 17 คำถาม - จะเข้าถึง query parameters ใน API route ของ Nuxt ได้อย่างไร? - โครงสร้างไฟล์ที่ถูกต้องสำหรับการสร้าง API route แบบไดนามิก /api/users/[id] คืออะไร? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Vue.js / Nuxt.js อื่นๆ - [พื้นฐาน JavaScript](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/javascript-fundamentals.md): 20 คำถาม, Junior - [JavaScript สมัยใหม่ (ES6+)](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/es6-modern-javascript.md): 20 คำถาม, Junior - [พื้นฐาน Vue](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vue-basics.md): 22 คำถาม, Junior - [คอมโพเนนต์ Vue](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vue-components.md): 20 คำถาม, Junior - [Vue Router](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vue-router.md): 18 คำถาม, Junior - [Pinia State Management](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/pinia-state-management.md): 20 คำถาม, Junior - [Vuex (Legacy)](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vuex-legacy.md): 15 คำถาม, Mid-Level - [Composition API](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/composition-api.md): 24 คำถาม, Mid-Level - [ระบบ Reactivity ของ Vue](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vue-reactivity.md): 20 คำถาม, Mid-Level - [พื้นฐาน Nuxt](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/nuxt-fundamentals.md): 22 คำถาม, Mid-Level - [การดึงข้อมูล (Data Fetching) ใน Nuxt](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/nuxt-data-fetching.md): 20 คำถาม, Mid-Level - [SSR และ SSG ใน Nuxt](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/nuxt-ssr-ssg.md): 22 คำถาม, Mid-Level - [โมดูล Nuxt](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/nuxt-modules.md): 18 คำถาม, Mid-Level - [Composables ใน Vue](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vue-composables.md): 20 คำถาม, Mid-Level - [ฟอร์มและการตรวจสอบ Vue](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vue-forms-validation.md): 20 คำถาม, Mid-Level - [การจัดการสถานะใน Nuxt](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/nuxt-state-management.md): 18 คำถาม, Mid-Level - [การทดสอบ Vue](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vue-testing.md): 20 คำถาม, Mid-Level - [การ Deploy Nuxt และ CI/CD](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/nuxt-deployment-cicd.md): 22 คำถาม, Mid-Level - [ประสิทธิภาพของ Vue](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vue-performance.md): 22 คำถาม, Senior - [รูปแบบขั้นสูงของ Vue](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vue-advanced-patterns.md): 24 คำถาม, Senior - [TypeScript กับ Vue](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/typescript-vue.md): 22 คำถาม, Senior - [การยืนยันตัวตน Nuxt](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/nuxt-auth.md): 20 คำถาม, Senior - [SEO ด้วย Nuxt](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/nuxt-seo.md): 20 คำถาม, Senior - [การทำ Internationalization ใน Nuxt](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/nuxt-i18n.md): 18 คำถาม, Senior - [สถาปัตยกรรม Vue](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vue-architecture.md): 22 คำถาม, Senior - [ความปลอดภัยของ Nuxt](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/nuxt-security.md): 20 คำถาม, Senior - [ระบบนิเวศ Vue](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/vue-ecosystem.md): 18 คำถาม, Senior - [การย้าย Vue 2→3 & Nuxt 2→3](https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/migration-vue2-vue3-nuxt2-nuxt3.md): 22 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/vue-nuxt/interview-questions/nuxt-server-routes