Last active
March 3, 2024 09:59
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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