Skip to content

Commit

Permalink
test upload 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Aweiro committed Nov 5, 2024
1 parent 69418b6 commit 5fa6684
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/photoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ fetch(`${baseUrl}/photos`)
return response.json();
})
.then(photos => {
const photosContainer = document.getElementById('photosContainer');

const photosContainer = document.getElementById('photosContainer');
if (!photosContainer) {
console.error("Елемент photosContainer не знайдено в DOM.");
return;
}

photos.forEach(photo => {
console.log('Фото:', photo); // Лог для перевірки отриманих даних

Expand Down
9 changes: 9 additions & 0 deletions js/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ app.get('/photos', async (req, res) => {
//2 ulpoad

app.post('/upload', upload.single('photo'), async (req, res) => {


console.log("Файл отримано для завантаження:", req.file);

if (!req.file) {
console.error("Файл відсутній у запиті.");
return res.status(400).json({ message: 'Не вдалося завантажити фото, файл відсутній.' });
}

const { description, decorName, price } = req.body;

if (!req.file) {
Expand Down

0 comments on commit 5fa6684

Please sign in to comment.