Why this error? Cannot read property 'params' of undefined - SOLVED


#1

I use Laravel/Vue/Vuetify/Vue-router

NAV

{ title: 'TIPS', icon: 'list', route: { name: 'tips', params: { tipsId: '4' }} },

page

<script>
import axios from 'axios';
console.log(this.$route.params.tipsId);
export default {

methods: {
  
    getPosts () {
  axios.get(this.baseUrl+this.baseApi, {
    params: {
      tipId: this.$route.params.tipsId

error:

Uncaught TypeError: Cannot read property 'params' of undefined
    at eval (tips.vue?e123:136)

My tipController (not meteor but Laravel)

    public function GetTips(Request $request)
    {

        $tipId = $request->tipId;

        $tips = Tips::where('Tips_kat', $tipId)
        ->get();
           
      return response()->json($tips, 200);

It works when I write

   params: {
      tipId: 4

#2

Solved:

changed:

baseUrl: ‘./api/’,

TO

baseUrl: ‘/api/’,

it looked for content in the wrong dir