Skip to content Skip to sidebar Skip to footer

Javascript Effiency With Apis

I was wondering if the code I have written is efficient (I am getting what I want), but it doesn't look appealing. Is there a better way to write this? require('es6-promise').poly

Solution 1:

you can use async/await

async function get_height() {

    const height_url = 'https://somewebsite.info/api/someth/tip/height';

    var data = await (await fetch(height_url)).json();

    console.log("The current height is " + data)
}

Post a Comment for "Javascript Effiency With Apis"