Error passing json value from web api to ngfor

1

This is the error you are making when making the api call. Do you think this is something at the end of the api or receiving it on my other project?

  

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

Api web code:

public IList<RepresentanteConsulta> ConsultaSelect(int? cod, string type)
    {
        try
        {
            using (ISession session = SessionFactory.OpenSession())
            {
                ClienteRepository cli = new ClienteRepository();
                IDictionary<String, object> dbParameters = new Dictionary<String, object>();
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("SELECT REPCN_REPRESENTANTE \"Codigo\", REPNM_REPRESENTANTE \"Nome\"");
                sb.AppendLine("FROM T_REPRESENTANTE REP JOIN T_REPRESENTANTE_X_CLIENTE REPCLI ON (REPCLI.ISN_REPRESENTANTE = REP.ISN_REPRESENTANTE) ");
                sb.AppendFormat("WHERE REPCLI.ISN_CLIENTE = {0} ", cod);
                return CreateSQLQuery<RepresentanteConsulta>(sb.ToString(), dbParameters);
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }

Call still on web controller api:

public JsonResult SelectPesquisa(int cod, string type)
    {
        switch (type)
        {
            case "rep":
                return Json(new { teste = representanteRepository.ConsultaSelect(cod, type) }, JsonRequestBehavior.AllowGet);
        }
        return Json(new { result = "Não implementado" }, JsonRequestBehavior.AllowGet);
    }

Call in other angled project:

switch (type) {
        case "rep":
            params = params.set('cod', formGroup.controls['codigoCliente'].value);
            this.retornaNomeApi(NEGOCIUS_API + '/Pesquisa/SelectPesquisa', params).subscribe(res => {this.teste = res;console.log(this.teste)})
            return this.teste;
    }
    
asked by anonymous 05.06.2018 / 13:48

0 answers