mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 15:28:47 +00:00
Allow useWidgetAPI to not actually send a request
This commit is contained in:
parent
774ca4b3b2
commit
c92d1caf80
2 changed files with 10 additions and 4 deletions
|
@ -7,7 +7,11 @@ export default function useWidgetAPI(widget, ...options) {
|
|||
if (options && options[1]?.refreshInterval) {
|
||||
config.refreshInterval = options[1].refreshInterval;
|
||||
}
|
||||
const { data, error, mutate } = useSWR(formatProxyUrl(widget, ...options), config);
|
||||
let url = formatProxyUrl(widget, ...options)
|
||||
if (options[0] === "") {
|
||||
url = null
|
||||
}
|
||||
const { data, error, mutate } = useSWR(url, config);
|
||||
// make the data error the top-level error
|
||||
return { data, error: data?.error ?? error, mutate }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue