Search code examples
aspnetboilerplate

How to parse _data to an array?


I have an API like this:

 public class Calendar : FullAuditedEntity
    {
        public string EventName { get; set; }
        public string Description { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
    }

public List<Calendar> GetCalendar()
        {
            var result =  _calendarRepository.GetAll().ToList();
            return new List<Calendar>(result.MapTo<List<Calendar>>());
        }

I can call to this API successfully from view and returned data in Swagger:

var _$calendarService = abp.services.myproject.calendar;
var _data = _$calendarService.getCalendar();

Here is the value of _data:

Object { resolve: Deferred/</e[f[0]](), resolveWith: fireWith(a, c), reject: Deferred/</e[f[0]](), rejectWith: fireWith(a, c), notify: Deferred/</e[f[0]](), notifyWith: fireWith(a, c), state: state(), always: always(), then: then(), promise: promise(a), 4 more… }

So how can I parse this _data to an array to use (not jTable)


Solution

  • getCalendar is a jquery.ajax call that returns jqXHR.

    _$calendarService.getCalendar().done(function (data, textStatus, jqXHR) {
        var items = data.items;
        var totalCount = data.totalCount;
        // ...
    });