85 try {
86 const product = createProduct(data as Product);
87 await axios.post(`${PRODUCTS_URL}` + ".json", product);
88 const response = await axios.get(`${PRODUCTS_URL}` + ".json"); 89 const result = Object.keys(response.data).map((key) => {
90 const product = response.data[key];
91 product.id = key;
84 async (data: Partial<Product>) => {
85 try {
86 const product = createProduct(data as Product);
87 await axios.post(`${PRODUCTS_URL}` + ".json", product); 88 const response = await axios.get(`${PRODUCTS_URL}` + ".json");
89 const result = Object.keys(response.data).map((key) => {
90 const product = response.data[key];
70 }
71 console.log(product.data);
72 const response = await axios.patch(
73 `${PRODUCTS_URL}/${data.id}` + ".json", 74 product.data
75 );
76 return response.data;
54 "categories/editProduct",
55 async (data: { id: string; newProduct: Partial<Product> }) => {
56 try {
57 const product = await axios.get(`${PRODUCTS_URL}/${data.id}` + ".json"); 58 product.data = { ...data.newProduct };
59 if (
60 product.data.price !== undefined &&
42 async (data: { body: string }) => {
43 try {
44 const response = await axios.delete(
45 `${PRODUCTS_URL}/${data.body}` + ".json" 46 );
47 return response.data;
48 } catch (error) {
It's unnecessary to concatenate two string literals together, such as:
let foo = "a" + "b";
This code is likely the result of refactoring where a variable was removed from the concatenation (such as "a" + b + "b"). In such a case, the concatenation isn't important and the code can be rewritten as:
let foo = "ab";
let a = `some` + `string`;
// these are the same as "10"
a = '1' + '0';
a = '1' + `0`;
a = `1` + '0';
a = `1` + `0`;
// when a non string is included
let c = a + b;
c = '1' + a;
let a = 1 + '1';
c = 1 - 2;
// when the string concatenation is multiline
c = "foo" + "bar";