DEV Community

loading...

Discussion on: Singleton Pattern in JavaScript

Collapse
andrewrothman profile image
Andrew Rothman

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);
    }
}
Collapse
aakatev profile image
Artem Author

Yes, this is another way of doing it.