mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-03 09:10:31 +00:00
15 lines
522 B
TypeScript
15 lines
522 B
TypeScript
|
import { createError } from '../composables/error'
|
||
|
|
||
|
const intervalError = '[nuxt] `setInterval` should not be used on the server. Consider wrapping it with an `onNuxtReady`, `onBeforeMount` or `onMounted` lifecycle hook, or ensure you only call it in the browser by checking `import.meta.client`.'
|
||
|
|
||
|
export const setInterval = import.meta.client ? window.setInterval : () => {
|
||
|
if (import.meta.dev) {
|
||
|
throw createError({
|
||
|
statusCode: 500,
|
||
|
message: intervalError
|
||
|
})
|
||
|
}
|
||
|
|
||
|
console.error(intervalError)
|
||
|
}
|