FatturaCheck

פרמיום
על ידי Simon Tribus | מְעוּדכָּן a month ago | Business
פּוֹפּוּלָרִיוּת

9.1 / 10

חֶבִיוֹן

112ms

רמת שירות

100%

Health Check

N/A

חזרה לכל הדיונים

How can I save the pdf in response body?

Rapid account: Stefino 76
Stefino76
2 years ago

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 2 years ago

It’s works!
Thank you very much.

Rapid account: Simontribus 1996
simontribus1996 Commented 2 years ago

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>

הצטרף לדיון - הוסף תגובה למטה:

התחבר / הירשם כדי לפרסם תגובות חדשות