R
Railway7mo ago
Z3R0

Railway display PDF

I need railway to read the html code that I have inside the directory to show the user the pdf that was downloaded or show the user the pdf or another message that returns from the server
7 Replies
Percy
Percy7mo ago
Project ID: N/A
Z3R0
Z3R07mo ago
dsx-consulta-cnd.up.railway.app
Z3R0
Z3R07mo ago
Z3R0
Z3R07mo ago
<!DOCTYPE html> <html lang="en" xml:lang="en"> <head> <title>Consulta de Certidão</title> </head> <body> <h2>Consulta de Certidão</h2> <form id="consultaForm"> <label for="NI">CPF/CNPJ:</label><br> <input type="text" id="NI" name="NI"><br> <input type="submit" value="Consultar"> </form> <!-- Elemento para exibir a mensagem --> <div id="message"></div> <!-- Elemento para exibir o PDF --> <iframe id="pdfViewer" style="width: 1200px; height: 1700px;"></iframe> <script> document.getElementById('consultaForm').addEventListener('submit', function(event) { event.preventDefault();
var cpf_cnpj = document.getElementById('NI').value;
fetch('/consulta', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({NI: cpf_cnpj}), }) .then(response => { if (response.status === 200 response.status === 202 response.status === 201) { return response.blob(); } else { throw new Error(response.status); } }) .then(data => { var url = URL.createObjectURL(data); document.getElementById('pdfViewer').src = url; }) .catch((error) => { console.error('Error:', error); var message = document.getElementById('message'); if (error.message === '3' || error.message === '4') { message.textContent = "Para todos os efeitos a certidão simplesmente não pôde ser emitida. Acesse https://cav.receita.fazenda.gov.br/autenticacao/login para verificar a situação fiscal."; } else { message.textContent = "Ocorreu um erro ao processar a sua solicitação. Por favor, tente novamente mais tarde."; } }); });
</script>
</body> </html>
Brody
Brody7mo ago
I'm sorry but these help threads aren't intended for programming help
Z3R0
Z3R07mo ago
How can I get help with this ?
Brody
Brody7mo ago
maybe check places like stack overflow, watch some YouTube videos, ask in a discord that specialises in programming help. these help threads are for railway related topics / issues, but your question is just a general programming question. I wish you all the best as you work through your project!