Skip to content

Commit

Permalink
Add response.text() from fetch() in README example
Browse files Browse the repository at this point in the history
When recently updating the usage examples in the README,
it blooper was introduced where `response.text()` was forgotten
when retrieving a mustache template with `window.fetch()`.
  • Loading branch information
phillipj committed Jan 11, 2020
1 parent 185fd6b commit bd742d5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.md
Expand Up @@ -169,11 +169,13 @@ If your templates reside in individual files, you can load them asynchronously a
```js
function renderHello() {
fetch('template.mustache').then(function (template) {
var template = document.getElementById('template').innerHTML;
var rendered = Mustache.render(template, { name: 'Luke' });
document.getElementById('target').innerHTML = rendered;
});
fetch('template.mustache')
.then((response) => response.text())
.then((template) => {
var template = document.getElementById('template').innerHTML;
var rendered = Mustache.render(template, { name: 'Luke' });
document.getElementById('target').innerHTML = rendered;
});
}
```
Expand Down

0 comments on commit bd742d5

Please sign in to comment.