Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const fetchData = async (url, opts) => {
try {
setQuery({ url, ...opts })
setError(null)
setStatus('fetching')
const { data } = await mql(url, { ...mqlOpts, ...opts })
setData(data)
setStatus('fetched')
} catch (err) {
setStatus('error')
setError(err)
}
}
async function fetchData () {
const { data } = await mql(url, {
meta: false,
iframe: true
})
setIframe(data.iframe)
}
fetchData()
const fetchAndSetData = async url => {
try {
const { data } = await mql(url, { iframe: true })
setData(data)
} catch (err) {}
}
const createApiUrl = ({ url = 'https://example.com', ...props } = {}) => {
const [apiUrl] = mql.getApiUrl(url, props)
return apiUrl
}
export const getApiUrl = ({
apiKey,
contrast = false,
data,
force,
headers,
media,
prerender,
proxy,
ttl,
url
}) =>
createApiUrl(url, {
apiKey,
audio: media.includes('audio'),
data,
force,
headers,
iframe: media.includes('iframe'),
palette: contrast,
prerender,
proxy,
screenshot: media.includes('screenshot'),
ttl,
video: media.includes('video')
})
export default (url, opts) => {
const [screenshotUrl] = getApiUrl(url, {
...opts,
screenshot: true,
meta: false,
embed: 'screenshot.url'
})
return screenshotUrl
}