nuxt3-directus-starter icon indicating copy to clipboard operation
nuxt3-directus-starter copied to clipboard

API issue

Open quentinglorieux opened this issue 3 years ago • 11 comments

Hi I struggle to make the API call in the ExamplesApiRoutes to work. the sayHello function doesnt work with a dynamic name.value using v-bind but it does with a static param (see bellow)

async function sayHello() {
  const { data } = await useFetch('/api/hello', {
    params: {
       name: name.value,
      //name: 'quentin', this works but name.value doesnt ?
    },
  })
  response.value = data.value
  loading.value = false
}

Maybe it comes from the useQuery in the hello.js file ?


const query = useQuery(event)
  return {
    message: `Hello ${query.name} 👋`,
  }
})

Any idea ?

quentinglorieux avatar Nov 08 '22 11:11 quentinglorieux

Let me test this

bryantgillespie avatar Nov 08 '22 13:11 bryantgillespie

Check out this commit and see if that doesn't solve it for you https://github.com/bryantgillespie/nuxt3-directus-starter/commit/250328265d903bb4ae17628225f246d588bb68b0

bryantgillespie avatar Nov 08 '22 13:11 bryantgillespie

Great, didnt know about the cache issue. Thx Q

quentinglorieux avatar Nov 13 '22 20:11 quentinglorieux

Just a related question. Let's say I have opened a slug page after fetching with the content compoment. The if I reload the slug page I obtain an error 500 Cannot read property 'title' of null at processTicksAndRejections (internal/process/task_queues.js:95:5)

I dont get why we loose the property ?

quentinglorieux avatar Nov 13 '22 20:11 quentinglorieux

Just a related question. Let's say I have opened a slug page after fetching with the content compoment. The if I reload the slug page I obtain an error 500 Cannot read property 'title' of null at processTicksAndRejections (internal/process/task_queues.js:95:5)

I dont get why we loose the property ?

Looks like I need to do some updates. I think this is probably because I updated this to the latest RC

Found this on their documentation. https://v3.nuxtjs.org/bridge/bridge-composition-api#usemeta

Looks like useMeta is now deprecated.

Should probably be using the useHead composable instead.

useMeta({
  title: page.value.title,
})

should be

useHead({
  title: page.value.title,
})

bryantgillespie avatar Nov 14 '22 20:11 bryantgillespie

I amended to useHead and I can read fine in Postman the GET request, but in the either Safari or Brave I get:

Captura de ecrã 2022-11-16, às 23 52 46 Captura de ecrã 2022-11-16, às 23 57 40

The database is already on AWS RDS but it shouldn't be the case It is public file and role but I am authenticated successfully and everything else is working.

staminna avatar Nov 16 '22 23:11 staminna

The error you're seeing there is coming back from your Directus instance. So there's likely something wrong with your call to the Directus API or the permissions aren't set correctly on your Directus instance.

bryantgillespie avatar Nov 17 '22 14:11 bryantgillespie

Looks like useMeta is now deprecated.

Should probably be using the useHead composable instead.

useMeta({
  title: page.value.title,
})

should be

useHead({
  title: page.value.title,
})

It was indeed deprecated but I still have the same issue. I think its more related to the fetching method.

Screenshot 2022-11-17 at 16 40 46

Error I have:

[Vue warn]: Unhandled error during execution of setup function 
  at <[slug] onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >

quentinglorieux avatar Nov 17 '22 15:11 quentinglorieux

The error you're seeing there is coming back from your Directus instance. So there's likely something wrong with your call to the Directus API or the permissions aren't set correctly on your Directus instance.

I am using unmodified Docker Image on my localhost and set read permissions for Pages, Images and the next one right bellow. I also did not change the code on the call or any other part from your repository.

staminna avatar Nov 17 '22 18:11 staminna

I am using unmodified Docker Image on my localhost and set read permissions for Pages, Images and the next one right bellow. I also did not change the code on the call or any other part from your repository.

Then it sounds like there may be an issue with the way I'm making the call to the API then.

I'll investigate further but will be a few days before I have time to dive into it.

bryantgillespie avatar Nov 17 '22 19:11 bryantgillespie

I am using unmodified Docker Image on my localhost and set read permissions for Pages, Images and the next one right bellow. I also did not change the code on the call or any other part from your repository.

Then it sounds like there may be an issue with the way I'm making the call to the API then.

I'll investigate further but will be a few days before I have time to dive into it.

https://github.com/bryantgillespie/nuxt3-directus-starter/pull/24

:)

BlackDahlia313 avatar Jun 12 '23 01:06 BlackDahlia313