Build api url as URL instance

This commit is contained in:
Sam Carlton 2022-04-26 12:24:26 -05:00
parent 65ced880c4
commit 7d0c6b182a

View file

@ -34,21 +34,24 @@ const {
} = Astro.params
const apiUrl = `${ import.meta.env.PUBLIC_API_DOMAIN }/api/app/spotify.json`
const apiUrl = new URL( import.meta.env.PUBLIC_API_DOMAIN )
apiUrl.pathname = `/api/${ Astro.site.pathname }.json`
// Astro Request reference
// https://docs.astro.build/en/reference/api-reference/#astrorequests
console.log('Astro.params', Astro.params )
console.log('apiUrl', apiUrl )
console.log('Astro.request', Object.keys( Astro.request ) )
console.log('Astro.request.url', Astro.request.url )
console.log('Astro.site.pathname', Astro.site.pathname )
console.log('Astro.request', Astro.request )
const appEntry = await axios.get(apiUrl)
const appEntry = await axios.get( apiUrl.toString() )
.then( response => {
console.log('response', response )
return response.data
// console.log( 'response', response )
return response.data.data
})