Answer the question
In order to leave comments, you need to log in
How to send photos (Express, PostgreSQL) to the client side (React), where and how to store them?
Hello, this is the situation. I need to send a JSON file with a product description (title, description, price) from the server, which, in turn, I get from the database (PostgreSQL). But along with the description, you need to send a photo of the product. At the moment, the photos are in a separate folder on the server side (Node, Express). I would like to know how to correctly send photos to the client (React)?
DB query:
const getAllProducts = async () => {
const data = await pool.query('select * from products');
return data.rows;
};
router.get('/api/products', async (req, res) => {
await db.getAllProducts().then((data) => {
res.status(200).send(data);
});
});
componentWillMount() {
axios('/api/products').then((data) => {
this.setState(() => ({
products: data.data
}))
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question