[JavaScript]Promise

getCart(){
    return new Promise((resolve,reject) => {
        const url = 'url';
        fetch(url)
            .then((response)=>{
                if (!response.ok) {
                    throw new Error();
                }
                return response.json();
            })
            .then((json)=>{
                resolve(json);
            })
            .catch((error)=>{
                reject(error);
            });
    });
}

this.getCart()
.then((json)=>{
    
})
.catch((error)=>{

});