Home > database >  How to wait for API response
How to wait for API response

Time:07-02

I'm trying to make my API request wait for API response, i did this:

export async function foldercreator(language,date){

const paths = ["" ,"/" language , "/" language "/" "/kanban","/" language "/" "/LavagnaFornitore", "/" language "/" "/LavagnaPianificatore"];

for(let i=0; i<paths.length; i  ){
    var request = await require('request');
    var options = {
        'method': 'MKCOL',
        'url': "****"
        'headers': {
            'Authorization': 'Basic *******',
        },
    };
    await request(options, function (error, response) {
        if (error) throw new Error(error);
        console.log(response.body);
    });
}

CodePudding user response:

Because you don't have async function

  • Related