score:1

Accepted answer

you aren't waiting for all of your promises to resolve before logging the array, the main issue is that you don't return the promise from your map function, you could do:

const getdata = async () => {
    try {
        let array = [];
        const firstdata = await axios.get(`https://swapi.dev/api/films/1/`)
        await promise.all(
            firstdata.data["characters"].map(url=>{
                return axios.get(url).then(character=>{
                    array.push(character.data.name);
                })
            })
        ).then(result=>{
            console.log("array:",array);
            json.stringify(array);
        })
    } catch (err ) {
        // errors
        console.log(err,"connection error")
    }
}

Related Query

More Query from same tag