Files
logapi_nuxt/server/api/surkon/post2/index.post.ts
2024-12-16 13:49:33 +07:00

22 lines
691 B
TypeScript

import axios from "axios";
export default defineEventHandler(async (event) => {
// Read the body of the incoming request
const body = await readBody(event);
// console.log(body)
console.log("masuk")
try {
const response = await axios.post("http://10.10.150.129:8082/api/suratkontrol/carinew", body)
// const response = await axios.post("http://10.10.150.129:8082/api/suratkontrol/insert/", body);
// console.log(response)
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",
});
}
});