szurubooru/client/js/models/info.js
rr- c21309aa35 client/models: don't modify API responses
API responses are cached internally - if they're modified, they're
modified in cache too. This can lead to certain anomalies, that can be
easily solved by making object copies.
2016-08-27 15:39:47 +02:00

24 lines
646 B
JavaScript

'use strict';
const api = require('../api.js');
const Post = require('./post.js');
class Info {
static get() {
return api.get('/info')
.then(response => {
return Promise.resolve(Object.assign(
{},
response,
{
featuredPost: response.featuredPost ?
Post.fromResponse(response.featuredPost) :
undefined
}));
}, response => {
return Promise.reject(response.errorMessage);
});
}
}
module.exports = Info;