0

Я хочу получить список фильмов из API Rotten Tomatoes, все выглядит хорошо, даже хром не дает мне никакой ошибки, но данные не отображаются в приложении. Я буду вставлять свой взгляд, хранить и моделировать, поскольку я считаю, что это может помочь. Спасибо в ожидании ответаПроблемы с получением результатов от Rotten Tomatoes api

tmdbModel.js

Ext.define("cinema.model.tmdbModel", { 

    extend: 'Ext.data.Model', 

    xtype: 'top_movies_model', 

    config: { 
     fields: [ 
      {name: 'id', mapping: 'movies.id'}, 
      {name: 'title', mapping: 'movies.title'}, 
      {name: 'year', mapping: 'movies.year'}, 
      {name: 'mpaa_rating', mapping: 'movies.mpaa_rating'}, 
      {name: 'runtime', mapping: 'movies.runtime'}, 
      {name: 'critics_consensus', mapping: 'movies.critics_consensus'}, 
      {name: 'release_dates', mapping: 'movies.release_dates.theater'}, 
      {name: 'critics_rating', mapping: 'movies.ratings.critics_rating'}, 
      {name: 'critics_score', mapping: 'movies.ratings.critics_score'}, 
      {name: 'audience_rating', mapping: 'movies.ratings.audience_rating'}, 
      {name: 'synopsis', mapping: 'movies.synopsis'}, 
      {name: 'poster_thumbnail', mapping: 'movies.posters.thumbnail'}, 
      {name: 'poster_profile', mapping: 'movies.posters.profile'}, 
      {name: 'poster_detailed', mapping: 'movies.posters.detailed'}, 
      {name: 'poster_original', mapping: 'movies.posters.original'}, 
      {name: 'abridged_cast_name', mapping: 'movies.abridged_cast.name'}, 
      {name: 'abridged_cast_id', mapping: 'movies.abridged_cast.id'}, 
      {name: 'abridged_cast_characters', mapping: 'movies.abridged_cast.characters'}, 
      {name: 'alternate_ids', mapping: 'movies.alternative_ids.imdb'}, 
      {name: 'links_self', mapping: 'movies.links.self'}, 
      {name: 'links_alternate', mapping: 'movies.links.alternate'}, 
      {name: 'links_cast', mapping: 'movies.links.cast'}, 
      {name: 'links_reviews', mapping: 'movies.links.reviews'}, 
      {name: 'links_similar', mapping: 'movies.links.similar'} 
     ] 
    } 
}); 

tmdbStore.js

Ext.define("cinema.store.tmdbStore", { 
    extend: 'Ext.data.Store', 

    requires: [ 
     'Ext.data.proxy.JsonP', 
     'cinema.model.tmdbModel', 
    ], 

    xtype: 'top_movies_store', 

    config: { 
     model: 'cinema.model.tmdbModel', 
     store: { 
      proxy: { 
       type: 'jsonp', 
       url: 'api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?apikey=[myApiKey]', 

       headers: { 
        'Accept' : 'application/json' 
       }, 

       reader: { 
        type: 'json', 
        root: 'movies' 
       }, 

       callbackKey: 'callback', 

       autoLoad: true 
      } 
     } 
    } 
}); 

Main.js - вид

Ext.define('cinema.view.Main', { 
    extend: 'Ext.Container', 
    xtype: 'main', 
    requires: ['Ext.TitleBar', 'Ext.DataView', 'cinema.store.tmdbStore'], 
    config: { 
     layout: { 
      type: 'card', 
      animation: 'slide' 
     }, 

     defaults: { 
      baseCls: 'back' 
     }, 

     animation: 'flip', 

     items: [ 
      { 
       xtype: 'titlebar', 
       title: 'Anakle Cinemas', 
       docked: 'top', 
       baseCls: 'flat title_font', 

       items: [ 
        { 
         html: '<img src="menu_butn.png">', 
         cls: 'flat border-right', 
         padding: '5 15 0 15', 
         align: 'left', 
         style: 'height: 100%', 
         itemId: 'menu_btn', 

         listeners: { 
          tap: function (button, e, eOpts) { 
           var cont = button.getParent().getParent(); 
           cont.setActiveItem(0); 
          } 
         } 
        }, 
        { 
         html: '<img src="share.png">', 
         cls: 'flat', 
         padding: '5 15 0 15', 
         align: 'right', 
         style: 'height: 100%', 
         itemId: 'share_btn' 

        } 
       ] 
      }, 
      { 
       xtype: 'panel', 
       defaultType: 'button', 
       //padding: '20 0 0 5', 
       defaults: { 
        ui: 'plain', 
        labelCls: 'btn_label', 
        cls: 'btn_color flat' 
       }, 
       items: [ 
        { 
         text: 'Top Movies', 
         listeners: { 
          tap: function (button, e, eOpts) { 
           var cont = button.getParent().getParent(); 
           cont.setActiveItem(1) 
          } 
         } 
        }, 
        { 
         text: 'Trailers', 
         listeners: { 
          tap: function (button, e, eOpts) { 
           var cont = button.getParent().getParent(); 
           cont.setActiveItem(2) 
          } 
         } 
        }, 
        { 
         text: 'Now Showing', 
         listeners: { 
          tap: function (button, e, eOpts) { 
           var cont = button.getParent().getParent(); 
           cont.setActiveItem(3) 
          } 
         } 
        } 
       ] 
      }, 
      { 
       xtype: 'panel', 
       items: [ 
        //{ 
         // xtype: 'titlebar', 
         //title: 'Top Movies' 
        // }, 
        { 
         xtype: 'dataview', 
         title: 'Top Movies', 
         store: 'tmdbStore', 
         styleHTMLContent: true, 
         itemTpl: new Ext.XTemplate(
          '<tpl for=".">', 
           '<div>{title}</div>', 
          '</tpl>' 
         ) 
        } 
       ] 
      }, 
      { 
       xtype: 'panel', 
       html: 'Trailers' 
      }, 
      { 
       xtype: 'panel', 
       html: 'Now Showing' 
      } 
     ] 
    } 
}); 

Обратите внимание, что я новичок в структуре, всего лишь 1 неделя, чтобы быть точным.

Я не хватает репутации размещать ссылки, следовательно, «связь» в некоторых частях и я ограничила результат только 1

{ 
    "movies": 
    [ 
     { 
      "id": "771322400", 
      "title": "The Purge", 
      "year": 2013, 
      "mpaa_rating": "R", 
      "runtime": 85, 
      "critics_consensus": "Half social allegory, half home-invasion thriller, The Purge attempts to use thriller formula to make an intelligent point -- but ultimately only ends up sinking in numbing violence and tired cliches.", 
      "release_dates": { 
       "theater": "2013-06-07" 
      }, 
      "ratings": { 
       "critics_rating": "Rotten", 
       "critics_score": 41, 
       "audience_rating": "Spilled", 
       "audience_score": 59 
      }, 
      "synopsis": "If on one night every year, you could commit any crime without facing consequences, what would you do? In The Purge, a speculative thriller that follows one family over the course of a single night, four people will be tested to see how far they will go to protect themselves when the vicious outside world breaks into their home. In an America wracked by crime and overcrowded prisons, the government has sanctioned an annual 12-hour period in which any and all criminal activity-including murder-becomes legal. The police can't be called. Hospitals suspend help. It's one night when the citizenry regulates itself without thought of punishment. On this night plagued by violence and an epidemic of crime, one family wrestles with the decision of who they will become when a stranger comes knocking. When an intruder breaks into James Sandin's (Ethan Hawke) gated community during the yearly lockdown, he begins a sequence of events that threatens to tear a family apart. Now, it is up to James, his wife, Mary (Lena Headey), and their kids to make it through the night without turning into the monsters from whom they hide. Directed by James DeMonaco (writer of Assault on Precinct 13 and The Negotiator), The Purge is produced by Jason Blum of Blumhouse (Paranormal Activity, Insidious, Sinister), Platinum Dunes' partners Michael Bay, Brad Fuller and Andrew Form (The Amityville Horror, The Texas Chainsaw Massacre), as well as Sebastien Kurt Lemercier (Assault on Precinct 13).(c) Universal", 
      "posters": { 
       "thumbnail": "link", 
       "profile": "link", 
       "detailed": "link", 
       "original": "link" 
      }, 
      "abridged_cast": [ 
       { 
        "name": "Ethan Hawke", 
        "id": "162660464", 
        "characters": [ 
         "James Sandin" 
        ] 
       }, 
       { 
        "name": "Lena Headey", 
        "id": "162653508", 
        "characters": [ 
         "Mary Sandin" 
        ] 
       }, 
       { 
        "name": "Max Burkholder", 
        "id": "770752375", 
        "characters": [ 
         "Charlie Sandin" 
        ] 
       }, 
       { 
        "name": "Adelaide Kane", 
        "id": "771075391", 
        "characters": [ 
         "Zoey Sandin" 
        ] 
       }, 
       { 
        "name": "Edwin Hodge", 
        "id": "770673719", 
        "characters": [ 
         "Bloody Stranger" 
        ] 
       } 
      ], 
      "alternate_ids": { 
       "imdb": "2184339" 
      }, 
      "links": { 
       "self": "link", 
       "alternate": "link", 
       "cast": "link", 
       "clips": "link", 
       "reviews": "link", 
       "similar": "link" 
      } 
     } 
    ] 
}
+0

Не могли бы вы также добавить JSON, который вы получите на свой пост. –

+0

Попробуйте обратиться к этому https://github.com/blessenm/SenchaMovies – blessenm

+0

TDeBailleul Я только что добавил результат JSON – chilas

ответ

0

Для начала, вы должны удалить фильмы из отображения (в определение модели), что позволит вам полностью удалить отображение из всех полей, которые не имеют дальнейшего вложенности, например:

fields: [ 
    {name: 'id'}, 
    {name: 'title'}, 
    ... 

в представлении, я вижу, что вы используете только поле «название», так если вам нужен только заголовок, вам не нужно определять всю модель, вы можете просто определить e, а остальные поля будут проигнорированы. Если вам действительно нужны все поля, вы захотите сделать что-то более сложное с полями, которые представляют собой массив, например «abridged_cast».

+0

Я на самом деле планирую использовать большинство из них, Извините за поздний ответ, я был на некоторое время. – chilas

+0

У вас есть идеи, как я могу работать с вложенными данными, спасибо в ожидании ответа – chilas

+0

Для простого вложения объектов вы сделали это почти правильно, просто удалите фильмы в начале '{name: 'critics_rating', mapping: ' ratings.critics_rating '} '. Для массивов это зависит от того, что вы хотите с ними делать. –

 Смежные вопросы

  • Нет связанных вопросов^_^