-4👍
You can use then method.
The then()
method returns a Promise
. It takes up to two arguments: callback functions for the success and failure cases of the Promise
.
Try something like this:
axios.get('{{url("/")}}/api/products?new=1&limit=6&order=desc&sort=created_at')
.then(response => {
// handle success
const products = response.data.data;
this.products = products;
let element = document.getElementById("sliderContainer");
element.classList.add("regular");
this.applySlider();
})
Minimal example:
axios.get('{{url("/")}}/api/products?new=1&limit=6&order=desc&sort=created_at')
.then(response => {
this.products = response.data.data;
document.getElementById("sliderContainer").classList.add("regular");
this.applySlider();
})
Check the full axios documentation rigth here.
Source:stackexchange.com