When I render OfferList through React Router, The result is a rejected promise, saying:
`An error occured when handling the DONE state of a fetch`
{
message: "Not found",
name: "Not found",
status: 404
}
When I render OfferList through React Router, The result is a rejected promise, saying:
`An error occured when handling the DONE state of a fetch`
{
message: "Not found",
name: "Not found",
status: 404
}
| import Marty from 'marty'; | |
| import API from './OfferAPI'; | |
| import Constants from './OfferConstants'; | |
| class OfferQueries extends Marty.Queries { | |
| getOffers(){ | |
| return API.getOffers().then(res => { | |
| return this.dispatch(Constants.RECEIVE_OFFERS, res.body.offers); | |
| }); | |
| } | |
| } | |
| export default Marty.register(OfferQueries); |
| import Marty from 'marty'; | |
| export default Marty.createConstants([ | |
| 'RECEIVE_OFFERS' | |
| ]); |
| import Marty from 'marty'; | |
| class OffersAPI extends Marty.HttpStateSource { | |
| constructor(options){ | |
| super(options); | |
| this.type = 'http'; | |
| this.id = 'OffersAPI'; | |
| this.baseUrl = '//redacted'; | |
| } | |
| getOffers(){ | |
| return this.get({ | |
| url: `/offer${window.location.search}`, | |
| cors: true | |
| }); | |
| } | |
| } | |
| export default Marty.register(OffersAPI); |
| import Marty from 'marty'; | |
| import OfferConstants from './OfferConstants'; | |
| import OfferQueries from './Queries'; | |
| class OffersStore extends Marty.Store { | |
| constructor(options){ | |
| super(options); | |
| this.state = []; | |
| this.id = 'Offers'; | |
| this.displayName = 'OffersStore'; | |
| this.handlers = { | |
| addOffers: Constants.RECEIVE_OFFERS, | |
| }; | |
| } | |
| getOffers(){ | |
| return this.fetch({ | |
| id: 'offers', | |
| remotely(){ | |
| return Queries.getOffers(); | |
| } | |
| }) | |
| } | |
| addOffers(offers){ | |
| this.state = this.state.concat(offers); | |
| this.hasChanged(); | |
| } | |
| } | |
| export default Marty.register(OffersStore); |
| import React from 'react'; | |
| import Marty from 'marty'; | |
| import OffersStore from '../stores/offers/OffersStore'; | |
| import OfferItem from './OfferItem'; | |
| class OfferList extends React.Component { | |
| render(){ | |
| console.log('whatevs, doesnt even reach here'); | |
| return ( | |
| <div></div> | |
| ); | |
| } | |
| } | |
| export default Marty.createContainer(OfferList, { | |
| listenTo: OffersStore, | |
| fetch(){ | |
| return { | |
| offers: OffersStore.getOffers() | |
| }; | |
| }, | |
| pending(){ | |
| return <div>Loading!</div>; | |
| } | |
| }); |