Object Creation Methods
What object creation pattern is suitable for creating service objects?
const createAPI = ({ endpoint, headers }) => ({
async get() {
return fetch(endpoint, { headers });
},
async post(data) {
return fetch(endpoint, {
method: 'POST',
headers,
body: JSON.stringify(data)
});
}
});