devServer: {
proxy: {
'/api': 'http://localhost:3001'
}
}
fetch('/api/translate', options);
const router = new express.Router();
router.route('/translate').post(TranslateController.somePostHandler);
app.use('/api', router);
resolve: {
extensions: ['.js', '.json', '.jsx', '.css', '.less'],
alias: {
Styles: path.resolve(__dirname, 'src/less/')
}
Справляться и эффективно работать - разные вещи.
const path = require('path');
const fs = require('fs');
const winston = require('winston');
const util = require('util');
const readFile = util.promisify(fs.readFile);
const logger = winston.createLogger({
level: 'debug',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.simple()
),
transports: [
new winston.transports.Console({
format: winston.format.combine(
winston.format.label({ label: module.filename.split('\\').slice(-2).join('\\') }),
winston.format.timestamp(),
winston.format.colorize(),
myFormat
)
}),
new winston.transports.Stream({
stream: fs.createWriteStream(path.resolve(__dirname, 'example.log'))
})
]
});
(async function() {
try {
await readFile('./fdsf', {encoding: 'utf8'});
} catch (e) {
Error.captureStackTrace(e);
logger.error(e.stack);
}
})();
2018-07-11T13:10:00.413Z [example\server.js] error: Error: ENOENT: no such file or directory, open 'D:\Development\frontend\example\fdsf'
at D:\Development\frontend\example\server.js:51:11
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
export default withRouter(
connect(
state => ({
componentState: state.globalComponentState
}),
dispatch => ({
someComponentMethod: payload => dispatch(componentActions.someActions(payload))
})
)(Component)
);
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:node/recommended",
"plugin:import/react",
"plugin:import/recommended",
"plugin:jsx-a11y/recommended",
"airbnb",
"prettier",
"prettier/react"
],
"plugins": ["babel", "react", "node", "import", "promise", "jsx-a11y", "prettier"]
$button.on('click', function(event) {
clickHandler(event);
});
var $selecttypeCategory = $('#selecttypeCategory');
var $fieldsAdvert = $('#fieldsAdvert');
var $categoryIdInput = $('#categoryIdInput');
var $advertIdInput = $('#advertIdInput');
function initChangeHandler() {
$selecttypeCategory.on('change', changeHanler);
$selecttypeCategory.trigger('change');
}
function changeHandler(event) {
var $this = $(this),
typeCategory_id = this.value;
alert(typeCategory_id);
if(typeCategory_id === '0') {
$fieldsAdvert.remove();
return false;
}
fetchData();
}
function fetchData() {
$.ajax({
url: 'index.php?route=ajax/getFielsCategoryListEdit',
data: {
id_cat: $categoryIdInput.val(),
id_adv: $advertIdInput.val()
},
type: 'POST',
success: function(data) {
updateData(data);
}
});
}
function updateData(data) {
$fieldsAdvert.remove();
if (data != '') {
var $newFieldsAdvert = $('<div id="fieldsAdvert"></div>');
$.map(data, function(v) {
switch (v.type) {
case 'text':
updateTextInputVal(v);
break;
case 'password':
updatePasswordVal(v);
break;
case 'select':
renderSelectOptions(v);
break;
case 'checkBox':
updateCheckboxes(v);
break;
case 'radio':
updateRadioInputs(v)
break;
case 'textarea':
case 'time':
case 'date':
case 'dateTime':
case 'hidden':
break;
default:
return 'Type of field not found';
}
});
$('#formElementsBlock').html($newFieldsAdvert);
}
}
$(function() {
initChangeHandler();
});