How to get data from key-value pairs in Vue.js
P粉418854048
2023-09-02 19:38:37
<p>I use rails on the backend and vue.js on the frontend. I'm trying to print the error just in case. Under <code>.catch</code> I get an error like below but cannot get the message from it. Please help me solve this problem. </p>
<pre class="brush:php;toolbar:false;">.catch(function (error) {
debugger
});</pre>
<p>In the console, if I try <code>error.response.data.error</code> this returns <code>'{:message=>"Amount is less than the minimum value"} '</code> I can't figure out how I can get only the message. </p>
<p>Wrong answer</p>
Your baclend is not serializing the object correctly. So the message is part of a string and not a JSON property. If you don't want to change you can use