如何获得一个数组而不是承诺?

时间:2021-03-26 18:31:37

标签: reactjs axios

告诉我,尝试在一个函数中发出 Axios 请求,然后回答另一个函数。 Promise 返回,但如何获取数组?必须不是在控制台中接收答案。日志()

# Setup test data
$Dirs = @(
    'Absolute Moebius - Volume 2 - The Long Tomorrow'
    ,'Absolute Moebius - Volume 3'
    ,'Agenzia X - Volume 1 - La Recluta'
    ,'Agenzia X - Volume 2 - Black Point'
    ,'Agenzia X - Volume 3 - Soli'
    ,'Akira - Volume 10'
    ,'Akira - Volume 20'
    ,'Akira - Volume 23'
    ,'Alan Ford - Volume 11 - Il Numero Uno'
    ,'Alan Ford - Volume 12 - La Triste Storia Di Un Giovane Ricco'
    ,'Alan Ford - Volume 13 - Golf'
)
foreach ($Dir in $Dirs) {
    if (-not (Test-Path -Path $Dir)) { New-Item -ItemType Directory -Path $Dir | Out-Null }
}

# Code to move files starts here vvvvvvvvvvvvvvvvvvvv
(Get-ChildItem -Directory -Filter '* - Volume*').Name |
    ForEach-Object {
        $NewDirName = $_.Split(' - ')[0]
        if (-not (Test-Path -Path $NewDirName)) { New-Item -ItemType Directory -Path $NewDirName | Out-Null }
        Move-Item -Path $_ -Destination $NewDirName
    }
# Code to move files ends here ^^^^^^^^^^^^^^^^^^^
export const get = (url) => {
     axios({
        method: 'get',
        url: url,
        credentials: 'include',
        mode: 'cors'
    })
         .then(response => {
         return response.data
         });
}

0 个答案:

没有答案