0

I'm doing a NodeJS/Angular program to retrieve data from SQL Server. However, when I try to get my data into a table, I get this error :

Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

Here's some parts of my code related to that error:

router.get('/', function (req, res) {
    Issues.getIssue(function (err, rows) {
                if (err) {
                    res.status(400).json(err);
                }
                else {
                    res.json(rows);
                }
            });
        });
ngOnInit() {
    this.issuesService
      .getIssue()
      .subscribe((data) => {
        this.issueslist = data;
        console.log(data);
      });
  }
  <tr *ngFor="let issue of issueslist">
    <td>{{ issue.Id_OnCall_Issue }}</td>
    <td>{{ issue.OnCall_Issue }}</td>
</tr>

Here's my full 'data' results from the console.log:

{recordsets: Array(1), recordset: Array(16), output: {…}, rowsAffected: Array(1)}
output: {}
recordset: Array(16)
0: {Id_OnCall_Issue: 1, OnCall_Issue: "Pb C"}
1: {Id_OnCall_Issue: 2, OnCall_Issue: "Pb  E"}
2: {Id_OnCall_Issue: 3, OnCall_Issue: "Pb S"}
3: {Id_OnCall_Issue: 4, OnCall_Issue: "Pb KISS"}
4: {Id_OnCall_Issue: 5, OnCall_Issue: "Pb BDD mongoDB"}
5: {Id_OnCall_Issue: 6, OnCall_Issue: "Pb BDD SQL Server"}
6: {Id_OnCall_Issue: 7, OnCall_Issue: "Pb R"}
7: {Id_OnCall_Issue: 8, OnCall_Issue: "Pb TR"}
8: {Id_OnCall_Issue: 9, OnCall_Issue: "Pb AWS"}
9: {Id_OnCall_Issue: 10, OnCall_Issue: "Pb KAFKA"}
10: {Id_OnCall_Issue: 11, OnCall_Issue: "Pb Data Center"}
11: {Id_OnCall_Issue: 12, OnCall_Issue: "Pb Réseau AWS"}
12: {Id_OnCall_Issue: 13, OnCall_Issue: "Pb Export"}
13: {Id_OnCall_Issue: 14, OnCall_Issue: "Pb API"}
14: {Id_OnCall_Issue: 15, OnCall_Issue: "Pb Storage"}
15: {Id_OnCall_Issue: 16, OnCall_Issue: "Pb K8S"}
length: 16
__proto__: Array(0)
recordsets: [Array(16)]
rowsAffected: [16]
__proto__: Object

How can I fix this please? Thanks in advance for your help!

4
  • 1
    Change the line this.issueslist = data; to this.issueslist = data.recordsets; Commented Nov 6, 2020 at 9:44
  • Thanks, but I get the error : Property 'recordsets' does not exist on type 'Object'. Commented Nov 6, 2020 at 9:47
  • 1
    That is a typescript error, use this.issueslist = (data as any).recordsets Commented Nov 6, 2020 at 9:49
  • Thank you so much @OwenKelvin, this.issueslist = (data as any).recordset solved it! I have my results now. Have a great day :D Commented Nov 6, 2020 at 9:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.