DEV Community

Discussion on: Singleton Pattern in JavaScript

Collapse
 
andrewrothman profile image
Andrew Rothman • Edited

This can also be done in ES6 like so:

import axios from "axios";

class Http {
    static get(url) {
        return axios.get(url);
    }

    static post(url) {
        return axios.post(url);
    }
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
hi_artem profile image
Artem

Yes, this is another way of doing it.