hello.js 650 B

123456789101112131415161718
  1. export default defineEventHandler(async (event) => {
  2. const baseUrl = import.meta.env.VITE_APP_BASE_URL
  3. // console.log('Base URL from env: ', baseUrl)
  4. if (event.method === 'GET') {
  5. const response = await fetch(baseUrl + '/country/baseCountry/getCountryCode')
  6. return response.ok ? response.json() : { msg: '获取国家信息错误' }
  7. }
  8. const response = await fetch(baseUrl + '/education/happyEntry/addHappyEntry', {
  9. method: 'post',
  10. headers: {
  11. 'Content-Type': 'application/json',
  12. project: '123'
  13. },
  14. body: await readBody(event)
  15. })
  16. return response.ok ? response.json() : { msg: '添加表单错误' }
  17. })