82 return;
83 }
84
85 const storageRef = ref(storage, "images/" + getValues("image")[0].name); 86 uploadBytes(storageRef, getValues("image")[0]).then((snapshot) => {
87 getDownloadURL(storageRef).then((url) => {
88 const product: Partial<Product> = {
73 );
74 navigate("/products");
75 } else if (ID.productId) {
76 const storageRef = ref(storage, "images/" + getValues("image")[0].name); 77 uploadBytes(storageRef, getValues("image")[0]).then((snapshot) => {
78 getDownloadURL(storageRef).then((url) => {
79 const product: Partial<Product> = {
23 "categories/getProducts",
24 async () => {
25 try {
26 const response = await axios.get(PRODUCTS_URL + ".json"); 27 const result = Object.keys(response.data).map((key) => {
28 const product = response.data[key];
29 product.id = key;
28 "categories/getCategories",
29 async () => {
30 try {
31 const response = await axios.get(CATEGORIES_URL + ".json"); 32 const result = Object.keys(response.data).map((key) => {
33 const category = response.data[key];
34 category.id = key;
129 // update cart in db
130 await axios.patch(`${CARTS_URL}/${newCart.id}` + ".json", newCart);
131 // return updated carts
132 const response = await axios.get(CARTS_URL + ".json");133 const result = Object.keys(response.data).map((key) => {
134 const cart = response.data[key];
135 return cart;
In ES2015 (ES6), we can use template literals instead of string concatenation.
var str = `Hello, ${name}!`;
var str = "Hello, " + name + "!";
var str = "Time: " + (12 * 60 * 60 * 1000);
var str = "Hello World!";
var str = `Hello, ${name}!`;
var str = `Time: ${12 * 60 * 60 * 1000}`;
var str = "Hello, " + "World!";