Files
logapi_nuxt/server/api/surkon/post/index.post.ts
2024-11-04 06:45:34 +07:00

23 lines
618 B
TypeScript

import axios from "axios";
export default defineEventHandler(async (event) => {
// Read the body of the incoming request
const body = await readBody(event);
try {
const response = await axios.post("http://localhost:8082/api/suratkontrol/cari", body, {
headers: {
"Content-Type": "application/json",
},
});
console.log(response.data)
return response.data
} catch (error) {
console.error("Error posting to surat kontrol API:", error);
throw createError({
statusCode: 500,
statusMessage: "Failed to fetch data from surat kontrol API",
});
}
});