So I am trying to connect 2 new Promise with each other so I can send information to each other. So I want to use image.url which is made in the first promise be used in the second promise but when I want to call image.url it is undefined. Does anyone have an idea to make this work? (Btw there is nothing between the code just want to make an difference between the 2 Promise).
First Promise:
image.promise = new Promise((resolve, reject) => {
const formData = new FormData();
formData.append('files', file);
axios
.post('http://api.resmush.it/', formData, { headers: { 'Content-Type': 'multipart/form-data' } })
.then(response => {
image.url = response.data.dest;
console.log("The compressed image url: ", image.url)
})
.catch(() => reject());
})
.then(response => {
image.status = STATUS_OK;
image.savings = response.data.percent;
})
Second Promise:
image.promise = new Promise((reject) => {
console.log(image.url);
function downloadFile() {
axios
.get('http://par3.static.resmush.it/1e5b76fc993169757c1319c027f5dca3/insta_logo.jpg')
.then(response => {console.log(response)})
// .then(response => resolve(response))
.catch(() => reject());
// .catch(reject => {console.log(reject)})
}
downloadFile();
}