mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-23 06:31:51 +00:00
add Article detail
This commit is contained in:
37
browser/main/Stores/PlanetStore.js
Normal file
37
browser/main/Stores/PlanetStore.js
Normal file
@@ -0,0 +1,37 @@
|
||||
var Reflux = require('reflux')
|
||||
var request = require('superagent')
|
||||
|
||||
var fetchPlanet = require('../Actions/fetchPlanet')
|
||||
|
||||
var updateSnippet = require('../Actions/updateSnippet')
|
||||
var fetchSnippets = require('../Actions/fetchSnippets')
|
||||
|
||||
var PlanetStore = Reflux.createStore({
|
||||
init: function () {
|
||||
// this.listenTo(updateSnippet, this.updateSnippet)
|
||||
// this.listenTo(fetchSnippets, this.fetchSnippets)
|
||||
this.listenTo(fetchPlanet, this.fetchPlanet)
|
||||
},
|
||||
// planetName = user.name/planet.name
|
||||
fetchPlanet: function (planetName) {
|
||||
request
|
||||
.get('http://localhost:8000/' + planetName)
|
||||
.send()
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
this.trigger(null)
|
||||
return
|
||||
}
|
||||
|
||||
var planet = res.body
|
||||
|
||||
this.trigger(planet)
|
||||
}.bind(this))
|
||||
},
|
||||
updateSnippet: function (input) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = PlanetStore
|
||||
Reference in New Issue
Block a user