MCPcopy Create free account
hub / github.com/basir/node-react-ecommerce / uploadFileHandler

Function uploadFileHandler

frontend/src/screens/ProductsScreen.js:78–97  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

76 dispatch(deleteProdcut(product._id));
77 };
78 const uploadFileHandler = (e) => {
79 const file = e.target.files[0];
80 const bodyFormData = new FormData();
81 bodyFormData.append('image', file);
82 setUploading(true);
83 axios
84 .post('/api/uploads', bodyFormData, {
85 headers: {
86 'Content-Type': 'multipart/form-data',
87 },
88 })
89 .then((response) => {
90 setImage(response.data);
91 setUploading(false);
92 })
93 .catch((err) => {
94 console.log(err);
95 setUploading(false);
96 });
97 };
98 return (
99 <div className="content content-margined">
100 <div className="product-header">

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected