isArticleHasMetaOrWhateverItIs() {
return Boolean(
this.article.section &&
this.article.title &&
this.article.description
);
}
isArticleHasMetaOrWhateverItIs() {
return !!(
this.article.section &&
this.article.title &&
this.article.description
);
}
loadJSON(onDataLoad);
const onDataLoad = data => {
console.log(data);
}
<Switch>
<Route path="/auth" component={Auth} />
<Route path="/" component={Main} />
</Switch>
<Switch>
<Route exact path="/auth" component={Auth} />
<Route path="/" component={Main} />
</Switch>
fetch('http://localhost:HOMEP_ПОРТА/')
.then(res => res.json())
.then(data => this.setState({ i: data.i }));
const fs = require('fs');
function getData(fileName, type) {
return new Promise(function(resolve, reject){
fs.readFile(fileName, type, (err, data) => {
err ? reject(err) : resolve(data);
});
});
}
Promise.all([
getData('small.txt', 'utf8'),
getData('big.txt', 'utf8'),
]).then(doSomethingWithResults);
const util = require('util');
const fs = require('fs');
const getData = util.promisify(fs.readFile);
Promise.all([
getData('small.txt', 'utf8'),
getData('big.txt', 'utf8'),
]).then(doSomethingWithResults);