Families of Musical Instruments
~/public/ **index.html**
~/src/helpers/ **text_format.js**
~/src/models
**person.js**
**random_adjective.js**
~/src/ **app.js**
Teas & Biscuits - Express Rest API
~/client/public/ **index.html**
~/client/src/models/ **consumables.js**
~/client/src/helpers
**pub_sub.js**
const PubSub = {
publish: function (channel, payload) {
const event = new CustomEvent(channel, {
detail: payload
});
document.dispatchEvent(event);
},
subscribe: function (channel, callback) {
document.addEventListener(channel, callback);
}
};
module.exports = PubSub;
**request.js**
const Request = function (url) {
this.url = url;
};
Request.prototype.get = function () {
return fetch(this.url)
.then((response) => response.json());
};
Request.prototype.post = function (payload) {
return fetch(this.url, {
method: 'POST',
body: JSON.stringify(payload),
headers: { 'Content-Type': 'application/json' }
})
.then(response => response.json());
};
module.exports = Request;