When calling the lookUpItem function from ItemSearch.vue I get undefined.
ItemSearch.vue
<script setup lang="ts">
import { lookUpItem } from '../systemApi'
async function getItemDetails() {
const response = await lookUpItem(mNumber, location)
}
</script>
systemAPI.ts
export async function lookUpItem(mNumber: number, location: number) {
getHash().then((hash) => {
axios.get(url)
.then((response) => {
// console.log(response) <- outputs the correct data to console.
return response
}
CodePudding user response:
You could try this:
For better reading (and understanding)
export async function lookUpItem(mNumber: number, location: number) {
try{
const hash = await getHash();
const response = await axios.get(url);
return response;
}catch(err){
throw err;
}
}