In my nuxtjs3 project, I would like to pick the data I get from an API.
In this case, I use jsonPlaceholder. I have no problem when it comes to picking data from an object:
const { data: useFetchOnly } = await useFetch('https://jsonplaceholder.typicode.com/todos/1', {
pick: ['title']
})
console.log({useFetchOnly})
but when I try to pick data from an array of objects, I do not know, how to do it. I tried with the following, but without success:
const { data: useFetchArray } = await useFetch('https://jsonplaceholder.typicode.com/todos/', {
pick: ['title']
})
console.log({useFetchArray})
Any ideas on how to solve it?
The documentation, that I found is not helping in this case: LINK
Actually, you need
transforminstead ofpick:So your final code should look like this:
Also keep in mind that:
You can learn more in docs.