Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const response = await unsplash.search.photos(
query,
1 + Math.ceil(offset / limit),
limit
)
if (!response.ok) {
const err = new Error(
`unsplash error ${response.status} "${response.statusText}"`
)
err.status = response.status
throw err
}
const results = await toJson(response)
if (results.results) {
const sizes = ['small', 'regular'] // 'thumb', 'full'
console.log(
`unplash image search "${query}" => ${results.results.length} results (${results.total} total)`
)
const transformedResults = results.results
.map((result) => {
// console.log(JSON.stringify(result, null, 2))
let largest = null
let smallest = null
for (let i = 0; i < sizes.length; ++i) {
const image = result.urls[sizes[i]]
.then(x => toJson(x)));
}