I am connecting to my storage emulator with the following code:
const firebaseApp = initializeApp(appConfig.firebase)
storage = getStorage(firebaseApp)
connectStorageEmulator(storage, 'localhost', 9199)
This works fine when the emulator is running. It also works fine when the emulator is NOT running! if its not running I want to do something else like this:
if (emulatorIsConnectedAndEmulatorIsRunning) {
// do something
} else {
// do something else
}
How can I detect whether the emulator is running or not?
After doing a little bit of research and testing I found out that the firebase emulator hub waits for the functions and storage to start so you could do:
axios.get(`http://localhost:4000/`)
And if it returns 200 the functions, storage is up.