如題,功能是要做axios圖片上傳,取回上傳後位置的URL後,再用一個axios送出儲存GoodsId和圖片URL到資料庫
code如下,目前這樣寫會遇到 第一個axios沒有await的樣子,直接就跑去執行下面的code 導致要傳入的圖片URL報undefind
 const addBanner = async () => {
    let upIMG= new FormData()
    upIMG.append('file', image)  
    const config = {
      headers: { 'content-type': 'multipart/form-data' }
     }
    
    const uploadImgRes = await Axios.post(uploadURL, upIMG, config)
    
    let data2 = {
      slideshowCover: uploadImgRes.data.key, //key是上傳完返回的URL
      goodsId: goodsId,
      }
    const config2 = {
      headers: { 
        'Content-Type': "application/json",
        'token': token 
      }
    }
    const addBannerRes = await Axios.post(addURL, data2, config2)
    console.log(addRes.data.code);
    };
還請各位高手幫忙解答,感激不盡!
Google 兩篇參考
看看有沒有幫助
React/aSync/aWait 批次上傳圖片(用 Promise)
Axios 上傳圖片並即時預覽