question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular 5 - firestore Snapshotchanges "supplied parameters do not match any signature of call target"

See original GitHub issue

I have been at this for days… Even was following a course on Udemy to help me get started, and a recent one, Plus all the doc’s I looked at, it APPEARS as if I am doing everything correctly…

Below, there is a line where I am getting the snapshotchanges of a collect/doc/collection that I have. I have stored in it. And the line below that (commented out) returns fine, and I can get the valuechanges, but I need the doc.id so that I can update/set new values.

But every-way that I try to organize this, it continues to tell me one of a few things, Mostly: “supplied parameters do not match any signature of call target” (from the snapshot shown below), or references missing parameters such as ([“add” | “remove”…]). etc. Either I am definitely way off with something… or Something is wrong.

I even tried the version from the Documents, so no need to post those below. I was getting the same errors…

import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { AngularFirestore } from 'angularfire2/firestore';
import { map } from 'rxjs/operators';
import { Subject } from 'rxjs/Subject';
import { Observable } from 'rxjs/Observable';
import { Router } from '@angular/router';

import { ISnippet } from '../models/snippets.model';
import { AuthService } from '../../login/auth.service';

@Injectable()
export class SnippetsService {
  snippetsAdded = new Subject<ISnippet[]>();
  snippetsExist = new Subject<boolean>();
  snipObserve: Observable<any[]>;
  userID: string;

  constructor(private db: AngularFirestore,
              private router: Router,
              private authService: AuthService) {
    this.userID = this.authService.getUserID();
  }

  fetchAvailableSnippets() {
  }

  createdNewSnippet(snippet: ISnippet) {
    this.storeNewSnippet(snippet);
  }

  fetchCreatedSnippets() {
  const thing = this.db
      .collection('snippets')
      .doc(this.userID)
      .collection<any>('user-snippets');

     // this.snipObserve = thing.snapshotChanges()
     //  .map(result => {
     //    return result.map(doc => {
     //      const data = doc.payload.doc.data as ISnippet;
     //      const id = doc.paylod.doc.id;
     //      return { id, ...data}
     //    })
     //    }
     //  });

this.snipObserve = thing.snapshotChanges()
  .map(results => {
    return results.map((i) => {
      return {
        id = doc.paylod.doc.id,
        ...doc.paylod.doc.data()
      };
    });
   })
  .subscribe(result => {
     for (const res of result) {
       console.log(res.payload.doc.data());
     }
  });

    // this.db
    //   .collection('snippets')
    //   .doc(this.userID)
    //   .collection('user-snippets')
    //   .valueChanges()
    //   .subscribe((snippets: ISnippet[]) => {
    //     this.snippetsAdded.next(snippets);
    //     if (snippets.length) this.snippetsExist.next(true);
    //   });
  }

  updateSnippet(snippet: ISnippet) {
    const selectedSnip = snippet.id;
    this.db.doc<any>(`snippets/${this.userID}/user-snippets/${selectedSnip}`)
      .update(snippet);
  }

  private storeNewSnippet(snippet: ISnippet) {
    const itemId = this.db.createId();
    const createdAt = firebase.firestore.FieldValue.serverTimestamp();
    const item = { ...snippet, id: itemId, created_at: createdAt};
    this.db.collection('snippets').doc(this.userID).collection('user-snippets').add(item);
    if (!snippet.private) this.storePublicSnippet(snippet);
    else this.router.navigate(['dashboard']);
  }

  private storePublicSnippet(snippet: ISnippet) {
    this.db.collection('snippets').doc('public_snippets').collection('snippets').add(snippet);
    this.router.navigate(['dashboard']);
  }

}


Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mskinhocommented, Jul 11, 2018

@SGissubel Solution: fetchAvailableExercises() { this.fbSubs.push(this.db .collection(‘availableExercises’) .snapshotChanges().pipe( map(docArray => { return docArray.map(doc => { const data = doc.payload.doc.data() as Exercise; const id = doc.payload.doc.id; return { id, …data }; }); }))

0reactions
SGissubelcommented, Jul 11, 2018

I’m not really sure I understand the context here - without matching my nomenclature.

Plus that does’t 100% apply when you have to go inside of collection, then doc, then collection, etc.

But my last one was how I solved it already.

And I was not using pipes when I created this. Though it’s a good note to go back in and update some code!

Cheers!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Supplied parameters do not match any signature of call target
I am making an http get request but the Supplied parameters do not match any signature of call target. How do i correct...
Read more >
angular/angular - Gitter
Hello, Anyone got any idea of this error? C:\Users\JCDI>ng new inin The command "new" has an option without the required type and name ......
Read more >
extended-angular-firestore - UNPKG
The CDN for extended-angular-firestore. ... It must match any inequality. ... If a target is not in this\n * mapping, and it's in...
Read more >
Building an Eisenhower App with Ionic 4 Drag and Drop
In this tutorial we will walk through the steps of creating an Ionic App using the AngularFire package to connect our App to...
Read more >
Toaz - Info Flutter For Beginners PR | PDF | Class (Computer ...
If no return statement is provided, it assumes return null. If you ... most modern programming languages, these parameters can be named on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found