Move get asset function into same API file
This commit is contained in:
@@ -27,4 +27,38 @@ export const fetchAPI = async (query: string) => {
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a Directus asset URL from parameters
|
||||
*/
|
||||
export const getAssetUrlKey = (
|
||||
id: string,
|
||||
key: string
|
||||
) => {
|
||||
if (!id || !key) return null
|
||||
|
||||
return `${API_URL}/assets/${id}?key=${key}`
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a Directus asset URL from parameters
|
||||
*/
|
||||
// export const getAssetUrl = (
|
||||
// id: string,
|
||||
// width: number,
|
||||
// height: number,
|
||||
// quality?: number,
|
||||
// fit: string = 'inside',
|
||||
// format?: string
|
||||
// ) => {
|
||||
// let args = ''
|
||||
|
||||
// // Add arguments to URL if specified
|
||||
// if (quality) args += `&quality=${quality}`
|
||||
// if (format) args += `&format=${format}`
|
||||
|
||||
// return `${API_URL}/assets/${id}?width=${width}&height=${height}&fit=${fit}${args}`
|
||||
// }
|
||||
Reference in New Issue
Block a user