I have two Route in my api.php
.
Route::get('resume-list/{templateID}', 'BasicController@getAllResumes'); Route::get('resume/single/{id}', 'BasicController@getResume');
The first one works fine but the second route returns the html code of index page.
Below is the axios call for the route:
data() {
return {
id: this.$route.params.id,
data: {}
};
},
methods: {
loadData() {
axios.get("api/resume/single/" + this.id).then(response => {
console.log(response);
this.data = response;
});
}
},
created() {
this.loadData();
}
Function on backend
public function getResume($id)
{
return Basic::where('id', $id)->firstOrFail();
}
What is the cause for this code?
Bootstrap.js
window._ = require('lodash');
window.Popper = require('popper.js').default;
try {
window.$ = window.jQuery = require('jquery');
require('bootstrap');
require('admin-lte');
} catch (e) {}
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
let token = document.head.querySelector('meta[name="csrf-token"]');
if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}
$response = Basic::findOrFail($id); return response()->json($response);
simply do this and check – Akhtar Munirapi/single/resume/
but laravel route isresume/single/{id}
: one issingle/resume
the other isresume/single
– user3532758