Oni JavaScript Snippet for Visual Studio Code
The extension that provide JavaScript and umi snippets for using in Visual Studio Code.
To keep snippets to show on the top of suggestions for easy using, use this configuration.
{
"editor.snippetSuggestions": "top"
}
like: define、forof、forin、foreach、function...
'/api/hello'(req, res) {
res.end(`hello ${Math.random()}`);
},
setup({ dispatch, history }) {
return history.listen(({ pathname, query }) => {
if (pathname === '/') {
dispatch({ type: 'fetch', payload: query });
}
});
},
*fetch({ payload: { page = 1 } }, { call, put }) {
const { data, headers } = yield call(usersService.fetch, { page });
yield put({
type: 'save',
payload: {
data,
total: parseInt(headers['x-total-count'], 10),
page: parseInt(page, 10),
},
});
},
export function create(values) {
return request('/api/users', {
method: 'POST',
body: JSON.stringify(values),
});
}