Untitled

mail@pastecode.io avatar
unknown
plain_text
25 days ago
855 B
11
Indexable
Never
export default function OfferDetail() {
     const [errorText, setErrorText] = useState("");


     const addErrorText = async (newErrorMsg: string) => {
          let newErrorText = Object.assign(errorText);

          newErrorText += newErrorMsg + "\n";

          setErrorText(newErrorText);          
     }

     const addItemsClickHandler = async () => {
          await axios.get(`/api/GetItems?items=${itemsText}`, headers)
          .then(async (response) => {
               if (response.data[1].invalidItems.length > 0) {
                     for (let i = 0; i < response.data[1].invalidItems.length; i++) {
                          addErrorText(`Item ${response.data[1].invalidItems[i]} is not valid`);
                     }
               }
          })
          .catch((err) => {
               console.log("ERROR" + err);
          });
}
Leave a Comment