import { string } from 'alga-js'
import strapiHelper from "../../../../../utils/strapiHelper"

export default defineEventHandler(async (event) => {
  let data: any = {}
  const id = getRouterParam(event, 'id')

  try {
    //const res: any = await strapiHelper(event, `m-products?filters[M_Product_ID][$eq]=${id}`, 'GET', null)
    const res: any = await strapiHelper(event, `m-products/${id}?populate=image`, 'GET', null)
    if(res) {
      data = res
    }
  } catch(error: any) {
    data = {
      status: error.status || error.statusCode || 500,
      message: error.detail || error.message || error.statusMessage
    }
  }

  return data
})