FatturaCheck

FREEMIUM
Par Simon Tribus | Mise à jour hace un mes | Business
Popularité

9.2 / 10

Latence

121ms

Niveau de service

100%

Health Check

N/A

Retour à toutes les discussions

How can I save the pdf in response body?

Rapid account: Stefino 76
Stefino76
hace 2 años

I’ll try to read the response in javascript with bolob() but it’s readble only like json(). In body I can read the pdf file but if I save it like string in a file it isn’t readble? Is it converted in base64? Can provide to me an example about to view the pdf file? Thank’s

Rapid account: Stefino 76
Stefino76 Commented hace 2 años

It’s works!
Thank you very much.

Rapid account: Simontribus 1996
simontribus1996 Commented hace 2 años

Hi,

the following should work (it did for me with Firefox and Edge/Chromium):

<script src=“https://code.jquery.com/jquery-3.6.0.min.js” integrity=“sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=” crossorigin=“anonymous”></script>

<form id=“data”>
<input type=“file” name=“XML”></input>
<input type=“submit” value=“Submit”></input>
</form>

<script>

$(“form#data”).submit(function(e) {
e.preventDefault();
var data = new FormData(this);

const options = {
	method: 'POST',
	headers: {
		'X-RapidAPI-Key': 'YOUR_API_KEY',
		'X-RapidAPI-Host': 'fatturacheck.p.rapidapi.com'
	},
	body: data
};

fetch('https://fatturacheck.p.rapidapi.com/API/FatturaGetRicevuta', options)
	.then(response => response.blob())
	.then(response => {
		var fileURL = URL.createObjectURL(response);
		window.open(fileURL);
	})
	.catch(err => console.error(err));

});

</script>

Participez à la discussion - ajoutez un commentaire ci-dessous:

Connectez-vous / Inscrivez-vous pour publier de nouveaux commentaires