Updating the child JSON data format within a database using Vue.js

I am currently trying to update the rating value in the commented_type column. In Laravel, I typically use something like commented_type>rating for this purpose. However, I am unsure of how to accomplish this task using vue.js.

The JSON structure of the column is as follows:

commented_type
 {"type": "review", "rating": 5}



updateReview: function () {
    var reviewData = {
        id:584,
        commented_type>rating:'4',//Unfortunately, this method does not work
    };
    this.$http.patch('/review/584',reviewData).then((response) => {

        console.log(response.data);

    }, (response) => {
        // error callback
        console.log('error response review update')
    });
},

Answer №1

Is the data you are trying to access in JSON format at the moment? If so, consider using the JSON.parse() method in JavaScript to convert it into an object.

If not, it seems like you are interested in learning about property accessors in JavaScript. You can achieve this by following this example:

selected_element['value']

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Clicking to close tabs

I am currently working on implementing a tab functionality on my website and I want these tabs to be responsive. Here is the code snippet I have been using: function openCity(evt, cityName) { var i, tabcontent, tablinks; tabcontent = document.ge ...

Discover the geolocation data for post code 0821 exclusively in Australia using Google Maps Geocoding

I'm having trouble geocoding the Australian postcode 0821. It doesn't seem to reliably identify this postcode as being located within the Northern Territory, unlike 0820 and 0822 which work fine. Here's an example of what I'm doing: ...

Insert a character or icon into a :value

I am faced with a situation where I have two input text fields, each being assigned a value from an array stored in a state. The array contains two elements, one for each input field. However, I wish to append a symbol such as % or some additional text at ...

What is the best method for saving a JSON resource on my device?

When I make a JSON request, it provides me with various parameters, one of which is the name. I want to create a variable to cache this name parameter so that I can access it later in my app. For instance, if the name from JSON request is "david", I would ...

What is the issue with the character set?

Attempting to send request data from JavaScript to Java using JSON format. In JavaScript, the request body appears as: { "id": "3", "name": "Chicken pasta", "description": "Lets make chicken pasta", "category": "Unassigned", "favorite" ...

Restrict dropping items in HTML5 by only allowing the drop if the target div is

I am working on developing a user-friendly visual interface for creating simple graphics. The interface includes 10 image icons and 5 boxes where users can place these icons. Users have the freedom to select which icon they want to display and arrange them ...

Error encountered when attempting to send JSON data with special characters via a POST or PUT request using node.js's http.request()

While attempting to use the node.js http module to PUT a JSON data into CouchDB, I encountered an issue. The JSON included a special character "ä" which caused CouchDB to respond with an "invalid_json" error. However, once the special character was remove ...

Step-by-step guide on starting Edge with Open package on Windows 10

I am utilizing the Open package to launch URLs across different browsers. Unfortunately, there is a lack of comprehensive documentation on how to specifically launch with different browsers on various operating systems. After some experimentation, I have ...

Using Vee-validate and vuetify to create a dynamic checkbox group with v-for loop

I am encountering an issue with integrating vee-validate, vuetify, and v-for in my code. Here is the snippet: <ValidationProvider name="availableLanguages" rules="required" v-slot="{ errors }" > <v-row> ...

Tips for altering attributes in a child element produced through v-for in VueJs 3

In my coding setup, the parent component generates child components using the v-for directive: <div class="planlist"> <ul id="planOl"> <PlanLego v-for="action in store.plan" :v-if="actio ...

Employ the parameter within the main object

I currently have this code snippet in my function: add(messenger) { switch (messenger) { case 'skype': this.messengers = _.assign(this.messengers, {skype: ''}) break case 'telegram': this.messenge ...

The React form is only transmitting a single property from the state instead of the complete state

My current challenge involves sending form data from my react client to my nodejs server. The issue I am facing is that only the last property of the state gets sent to the server upon form submission. This problem seems to be occurring on the client side, ...

Converting a class-based component into a functional component

TL;DR : I am in the process of converting my class-based App component to a Functional component but encountering unexpected outcomes with the useEffect Hook. Being relatively new to React, I originally built my movie search app using a class-based approa ...

What are the benefits of implementing a hexadecimal strategy in javascript?

I have a somewhat unusual question that has been puzzling me. I've noticed some interesting choices in naming variables in JavaScript, seemingly using what appears to be "a hexadecimal approach". For example, I see variables named like _0x2f8b, _0xcb6 ...

What's the scoop on NodeJS, Express, Nginx, and Jade?

Currently exploring options for technologies and libraries to use in a new, large-scale project. With knowledge of NodeJS, JavaScript, Express, and Jade (now Pug), my team and I are leaning towards adopting these for the project. The main issue we're ...

What is the mechanism by which the useState hook in React determines the calling context?

After transitioning from using class components to functional components in React, I delved into the documentation with keen interest to understand how the useState hook functions. Upon consulting the FAQ page, it was explained that each component has an ...

The construction of the Gatsby site encountered a major obstacle

I've been facing challenges while trying to build my Gatsby site. Whenever I run 'gatsby develop' in the console, my app starts without any issues. However, when I attempt to build it, I encounter errors like the ones shown below. Does anyon ...

Angular's import and export functions are essential features that allow modules

Currently, I am working on a complex Angular project that consists of multiple components. One specific scenario involves an exported `const` object in a .ts file which is then imported into two separate components. export const topology = { "topolo ...

The presence of a .js file is causing a blockage in the loading

As a beginner in the world of jquery/web design, I decided to download a template to experiment and get more familiar with it. Unfortunately, I encountered an issue with a specific script that is causing my jQuery to not load properly. Here is the snippet ...

Elevate state in React to modify classNames of child elements

I have a structured set of data divided into 6 columns representing each level of the hierarchy. When a user makes selections, their chosen location is highlighted with a dynamic CSS class name and displays the relevant data list. I've managed to impl ...