export default async function fetchHelper(event: any, url: string, method: string = 'GET', token: string, body: any) {
  const config = useRuntimeConfig()
  //const logshipSession = getCookie(event, 'logship_session')
  const logshipToken = getCookie(event, 'logship_it') //await useStorage().getItem('logship_token_'+logshipSession)
  let options: any = {}
  if(token || logshipToken) {
    options = {
      ...options,
      headers: {
        'Content-Type': 'application/json',
        Accept: 'application/json',
        Authorization: 'Bearer '+(token || logshipToken)
      }
    }
  }
  if(body) {
    options = {
      ...options,
      body: body
    }
  }

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