Bonjour à toutes et à tous,

J'ai une page web qui interroge une API à l'aide d'un fetch()
La réponse obtenue est le contenu d'un fichier PDF que je voudrait afficher dans un nouvel onglet

Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
 fetch("url_api", {
            method: 'POST',
            body: formData,
 
        }).then((response) => response.text())
        .then((text) =>{
 
            var   newWindow = window.open();
 
            newWindow.document.write( text);
        }
Ce code ouvre bien un nouvel onglet au lieu d'afficher le PDF, j'ai "sa description"
%PDF-1.5 2 0 obj << /Filter /FlateDecode /Length 8 /Length1 0 >> stream x endstream endobj 3 0 obj << /Type /Page /Parent 1 0 R /MediaBox [0 0 842.25 595.50 ] /Resources
.......
......
/Root 5 0 R /Info 4 0 R /ID [] >> startxref 732 %%EOF
Est-ce que quelqu'un a une solution pour l'afficher "proprement"?