export default async function laravelHelper(event: any, url: string, method: string = 'GET', body: any = null) {
  const config = useRuntimeConfig()

  let options: any = {}
  if(body) {
    options = {
      ...options,
      body: body
    }
  }

  const headers: any = {
    Accept: 'application/json',
    'Content-Type': 'application/json',
  }
  // Shared secret for the authenticated Laravel groups (banking). Harmless for
  // the older unauthenticated groups — they ignore the header.
  if (config.api.laravelServiceToken) {
    headers['X-Logship-Service-Token'] = config.api.laravelServiceToken
  }

  return await $fetch(config.api.laravel+'/api/'+url, {
    method: method,
    headers: headers,
    ...options
  })
}
