Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular interceptor with AngularFire

Does anyone know is it possible to intercept the requests made to firebase cloudstore with AngularFire library ?

I would like to implement a functionality that shows a toast message in the angular interceptor when adding/updating/deleting items from the cloudstore

I am using AngularFire library and AngularFirestore.

My interceptor works fine for other http requests but not when when using the library only using the angular builtin HttpClient library. I can see in the network console that xhr request are made when adding/updating/deleting items from cloudfirestore.

How can I intercept the requests made from AngularFirestore library ?

I am using @angular/fire 5.1.2 and angular 7.2

Thanks, Jani

like image 837
jani_r Avatar asked May 11 '19 05:05

jani_r


Video Answer


1 Answers

The Angular interceptor only works for http request made with the http client. AngularFire uses the Firebase SDK for Firestore operations, which does not use the http client from Angular. So the requests can not be intercepted.

You could send a message inside the function which calls the operation. Or use background functions from Firebase Cloud Function.

like image 147
Sebastian Vischer Avatar answered Oct 20 '22 13:10

Sebastian Vischer