Node.js Examples
Node.js examples for calling BrandQL with fetch and strict fallbacks.
Node.js
Use fetch in modern Node, or drop the URL into your HTTP client of choice.
BrandQL responds with a redirect. Use res.url to get the final image URL.
const res = await fetch('https://api.brandql.com/logo/stripe.com')
// BrandQL responds with a redirect to the actual image.
// res.url is the final image URL after redirects.
const imageUrl = res.url
const params = new URLSearchParams({
variant: 'dark',
size: '128',
format: 'png',
fallback: 'false',
})
const url = `https://api.brandql.com/logo/stripe.com?${params}`
const res = await fetch(url)
if (!res.ok) {
throw new Error(`BrandQL returned ${res.status}`)
}
const imageUrl = res.url
Related
Was this page helpful?