Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
how to access the ReadableStream inside of the body of the Promise response

I have an mp3 file that I am caching as such:

const request = URL_TO_MY_MP3_FILE
caches.open("my-cache").then(cache => {
   cache.add(request);
});

I can see that the mp3 file is being cached in the Application tab: enter image description here

By the way, how do I ensure that file is cached as audio/mp3 and not audio/mpeg?

Later on, I would like to retrieve the mp3 file from cache so I can play it in the browser:

caches.open("my-cache").then(cache => {
     const response = cache.match(request);
     console.log(request, response);
     this.audio = new Audio(response.body);
})

enter image description here

My first question is how to access the ReadableStream inside of the body of the Promise response. Unfortunately, response.body is equal to undefined and I don't understand how to access the mp3 file otherwise.

Secondly, how do I ensure that file is cached as audio/mp3 and not audio/mpeg?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

I found the answer here: How to access the value of a promise?

caches.open("my-cache").then(cache => {
     const response = cache.match(request);
     console.log(request, response);
     response.then(function(result) {
        this.audio = new Audio(response.body);
     }.bind(this), false);
})
about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda