Home Reference Source

application/util/mock-fetch.js

const mockFetch = (data, status = 200) => {
    return new Promise((resolve, reject) => {
        process.nextTick(() => {
            return resolve(
                {
                    status: status,
                    json: () => {
                        return data;
                    }
                }
            );
        });
    });
};

if (!window.fetch) {
    window.fetch = () => {};
}

export default mockFetch;