mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 10:46:32 +00:00
add SnippetEditModal
This commit is contained in:
@@ -8,6 +8,7 @@ var PlanetStore = Reflux.createStore({
|
||||
init: function () {
|
||||
this.listenTo(PlanetActions.fetchPlanet, this.fetchPlanet)
|
||||
this.listenTo(PlanetActions.createSnippet, this.createSnippet)
|
||||
this.listenTo(PlanetActions.updateSnippet, this.updateSnippet)
|
||||
},
|
||||
fetchPlanet: function (planetName) {
|
||||
request
|
||||
@@ -47,6 +48,27 @@ var PlanetStore = Reflux.createStore({
|
||||
data: res.body
|
||||
})
|
||||
}.bind(this))
|
||||
},
|
||||
updateSnippet: function (id, input) {
|
||||
request
|
||||
.put('http://localhost:8000/snippets/id/' + id)
|
||||
.set({
|
||||
Authorization: 'Bearer ' + localStorage.getItem('token')
|
||||
})
|
||||
.send(input)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
this.trigger(null)
|
||||
return
|
||||
}
|
||||
|
||||
var snippet = res.body
|
||||
this.trigger({
|
||||
status: 'snippetUpdated',
|
||||
data: snippet
|
||||
})
|
||||
}.bind(this))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user