Skip to content

Instantly share code, notes, and snippets.

@M-Drummond
Last active March 3, 2024 09:59
Show Gist options
  • Save M-Drummond/c8c2b37717685843bac36b7ed82b7652 to your computer and use it in GitHub Desktop.
Save M-Drummond/c8c2b37717685843bac36b7ed82b7652 to your computer and use it in GitHub Desktop.
Vue/Axios - Fetch products via Axios and assign to a Pinia store
import axios from 'axios'
import { useGlobalStore } from '@/stores/global'
export async function getChildProductDataFromApi(child: { child_article_nbr: any }) {
const options = {
decompress: false
}
const url = `/apis/ui/products/${child.child_article_nbr}`
try {
const response = await axios.get(url, options)
useGlobalStore().selectedProduct.child_products.push(response.data[0])
} catch (error) {
console.log(error)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment