I upload to database like this :
My Object that I want to upload :
export class Data {
$key: string;
name: string;
address: string;
address2: string;
pscode: string;
ccode: string;
name2: string;
trucks: Trucks;
trailers: Trailers;
email: string;
phone: string;
city: string;
country: string;
}
**Upload service :**
getItem: Observable<Data[]>;
key: string;
busines = {} as Data;
createItemAuth() {
this.afAuth.authState.subscribe(auth => {
this.afDatabase.list(`users/${this.auth.userId}/company`).push(this.busines)
});
}
//this not works :
getUploads() {
this.getItem = this.afDatabase.list(`profile/${this.auth.userId}/company/`).snapshotChanges().map((actions) => {
return actions.map((a) => {
const data = a.payload.val();
const $key = a.payload.key;
const $ref = a.payload.ref;
return { $key, ...data, $ref };
});
});
return this.getItem;
}
on getUploads()
this.getItem
I get :
Type '{ $ref: Reference; $key: string; }[]' is not assignable to type 'Data[]'. Type '{ $ref: Reference; $key: string; }' is not assignable to type 'Data'. Property 'name' is missing in type '{ $ref: Reference; $key: string; }'.
Whats wrong with that ?