ryanpzr
ryanpzr
RRailway
Created by ryanpzr on 10/15/2023 in #✋|help
I need help to add a custom domain
I use Hostinger
74 replies
RRailway
Created by ryanpzr on 9/25/2023 in #✋|help
Fetch Failed
i wanna make a fetch with Railway server, every time I try to connect an error appears
17 replies
RRailway
Created by ryanpzr on 9/25/2023 in #✋|help
Fetch failed
Please help me with this problem guys! My website does not show the content that is in the database! Fetch: function carregarTodasBonecas() { // Solicita todas as bonecas ao servidor fetch('https://agulha-e-linha-production.up.railway.app/upload', { method: 'GET' // Especifica o método HTTP como GET }) .then(response => { if (response.ok) { return response.json(); } else { throw new Error('Erro ao buscar dados do servidor.'); } }) .then(data => { // Renderize as bonecas na tela data.forEach(boneca => { const novoItem = criarElementoBoneca(boneca); main.appendChild(novoItem); }); }) .catch(error => { console.error('Erro ao buscar dados:', error.message); }); } NodeJS: server.get('/upload', (req, res) => { // Consulta o banco de dados para obter todas as bonecas const sql = 'SELECT * FROM bonecas'; db.query(sql, (err, result) => { if (err) { console.error('Erro ao buscar bonecas no banco de dados:', err); return res.status(500).json({ error: 'Erro ao buscar bonecas' }); } else { // Retorna todas as bonecas encontradas no banco de dados return res.json(result); } }); });
3 replies