c21309aa35
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.
24 lines
646 B
JavaScript
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;
|