Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laravel_beginner's avatar

Getting data from database in vue.js by id

I want to get data from the database in script in my vue.js file. And I tried everything find function, where function and so on and I will always get the error str.replace is not a function(). Some examples of what I tried

this.data = this.packages.where("id", id)
this.data = this.packages.find(id)

An id is a type number. And I don't have this. before because I am calling it to the method, but even if I do the additional step and do

this.id = id
this.data = this.packages.find(this.id)

It does not have any effect. This is how the error looks like: https://imagizer.imageshack.com/img923/966/o4TfGA.png Any idea how I could solve this

0 likes
2 replies
Lumethys's avatar

your frontend should never access the database directly, the frontend call the backend, and the backend call the db

Please or to participate in this conversation.