I’m new to vue.js and I want to connect vue.js to my database.
I wanna create a website, to see all my manufacturers from my db.
I did a little research and saw that i could use axios to get a file,but the path that i passed along doesn’t work.
Here’s my folder:
customer
src
components
hello_world.vue
sql
manufacturer_conn.php
connection.php
this is my hello_world.vue
<template>
<div class="hello">
<div v-for="manufacturer in manufacturers" v-bind:key="manufacturer">
{{manufacturer}}
{{text}}
</div>
</div>
</template>
<script>
const axios = require('axios');
export default {
name: 'HelloWorld',
data:function(){
return{
manufacturers: ['hi','hello','to','you'],
text: 'hi-------',
}
},
beforeCreate(){
axios.get('customer/src/sql/manufacturer_conn.php')
.then(function (response) {
app.manufacturers = response.data;
})
.catch(function (error) {
console.log(error);
});
},
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
this is my manufacturer_conn.php code:
<?php
console.log('--hi--');
include 'config.php';
$manufacurer = mysqli_query($con,"select * from manufacurer");
$response = array();
while($row = mysqli_fetch_assoc($manufacurer)){
$response[] = $row;
}
echo json_encode($response);
exit;
ERROR:
GET http://localhost:8080/customer/src/sql/manufacturer_conn.php 404 (Not Found)
Error: Request failed with status code 404
at createError (createError.js?2d83:16)
at settle (settle.js?467f:17)
at XMLHttpRequest.handleLoad (xhr.js?b50d:59)
seems like my path is not right,can’t figure out what it should be.