download pdf with link provided raw data

I have a backend that returns some data, I need to use that data to create a pdf document that the user will download.

In my code I have the following:

const downloadLink = document.createElement('a');
downloadLink.href = href;
downloadLink.download = 'file.pdf';
downloadLink.click();

What I cannot figure out is what data format does the backend need to send for my frontend to be able to process and put into the href?


So far I have explored using blob but don't know what I should put there. I imagine something like

const href = new Blob(data, { type: 'application/pdf' });

But what should data be? Or am I even using the right method?