Andrei Fidelman
const jsDeveloper = !!!(+[] - +[]);
The mock does not mock you
Andrei Fidelman
// import ui from '../testServices/checkoutUI';
export const getUI = () => {
return (dispatch) => {
dispatch({ type: SHOPPING_CART_UI_FETCH });
// setTimeout(() => {
// dispatch({
// payload: ui
// });
// }, 3000);
axios.get(url)
.then((response) => {
const { payload } = response.data;
dispatch({ payload });
});
};
};
import ui from '../testServices/checkoutUI';
export const getUI = () => {
return (dispatch) => {
dispatch({ type: SHOPPING_CART_UI_FETCH });
setTimeout(() => {
dispatch({
payload: ui
});
}, 3000);
// axios.get(url)
// .then((response) => {
// const { payload } = response.data;
//
// dispatch({ payload });
// });
};
};
Development
Production
import { staticUI } from 'app.ws/checkoutUI';
export const createAC = (dev, prod) => {
if (process.env.NODE_ENV === 'development';) {
dev();
} else {
prod();
}
};
const prod = () => {
axios.get(url)
.then((response) => {
const { payload } = response.data;
dispatch({ payload });
});
};
const dev = () => {
setTimeout(() => {
dispatch({
payload: staticUI
});
}, 1500);
};
createAC(dev, prod);
const config = require('../config');
const gulp = require('gulp');
const jsonServer = require('json-server');
const api = () => {
const loginSuccess = {
success: true
};
return { mailingSuccess };
};
function start(cb) {
const app = jsonServer.create();
const router = jsonServer.router(api());
const middleware = jsonServer.defaults();
app.use(middleware);
app.use(router);
const server = app.listen(config.API_PORT, () => {
gutil.log(
gutil.colors.green(`JSON Server is running…`),
gutil.colors.gray(`http://localhost:${config.API_PORT}`)
);
});
}
gulp.task('api', start);
The mock does not mock you
Andrei Fidelman
By Andrei Fidelman
Simple Rest API mock server