FatturaCheck

FREEMIUM
By Simon Tribus | Updated il y a 25 jours | Business
Popularity

9.1 / 10

Latency

114ms

Service Level

100%

Health Check

N/A

Back to All Discussions

How can I save the pdf in response body?

Rapid account: Stefino 76
Stefino76
il y a 2 ans

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 il y a 2 ans

It’s works!
Thank you very much.

Rapid account: Simontribus 1996
simontribus1996 Commented il y a 2 ans

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>

Join in the discussion - add comment below:

Login / Signup to post new comments