I'm working on a small program in JavaScript. Basically, I want to use Promise and fetch to extract text out of two text files. However, I can't figure out how to get the actual text out of the files. Here's my current code.
sample.txt
this is
a sample
text file.
sample2.txt
this is
the second
sample file.
index.js
function getSampleText() {
Promise.all([
fetch('sample.txt'),
fetch('sample2.txt')
]).then(allResp => {
let sampleResp = allResp[0];
let sample2Resp = allResp[1];
console.log(sampleResp);
console.log(sample2Resp);
})
}
Here are the Promises...how do I get the text out of these?