How to use this map data with Dynamic routes?

vedees
0
vedees
commented 10 months ago

My code:

 return axios.all([
     axios.get('https://jsonplaceholder.typicode.com/users'),
     axios.get('https://jsonplaceholder.typicode.com/ico')
 ])
 .then(axios.spread((users, ico) => [...users.data, ...ico.data]))

How to use this?

 {
         url: '/page/2',
         changefreq: 'daily',
         priority: 1,
         lastmodISO: '2017-06-30T13:30:00.000Z'
 }


With Dynamic routes? Right now it's assigning only url.

0
NicoPennec
1.7k
NicoPennec
commented 9 months ago

you're just missing a transformation data step ๐Ÿ˜‰

        .then(axios.spread((users, ico) => [...users.data, ...ico.data]))
        .then(data => data.map(item => ({
          url: 'item/' + item.id,
          changefreq: 'daily',
          priority: 1,
          lastmodISO: new Date().toISOString()
        })))
0
Informations
Question โ€ข Unresolved
#c40 - Created 10 months ago