Can I change the names of the data retrieved from this API?

I'm looking to customize the names fetched from an external API in my

<span>{{stats.team.name}}</span>
.

Currently, the output displays full club names like:

Manchester City FC
Manchester United FC
Wolverhampton Wanderers FC

Instead, I would prefer shorter names like:

Man City
Man Utd
Wolves

Is there a straightforward way to achieve this?

This is how I have it set up in my HTML:

<div v-for="stats in tableStats" v-bind:key="stats.tableStats">
  <span>{{stats.team.name}}</span>
</div>

This is the API Call script:

<script>

import axios from 'axios'

export default {

    data () {
    return {
      tableStats: null
    }
  },

    mounted () {
    axios.get('https://api.football-data.org/v2/competitions/PL/standings', {
        headers: {
            'X-Auth-Token': 'mytoken',
            "Content-Type": "application/json",
            }
    })
      .then(response => (this.tableStats = response.data.standings[0].table))
  }
}

</script>

Here's a snippet of the JSON data retrieved:

"table": [
            {
                "position": 1,
                "team": {
                    "id": 65,
                    "name": "Manchester City FC",
                },
                "playedGames": 19,
                "form": "W,W,W,W,W",
                "won": 12,
                "draw": 5,
                "lost": 2,
                "points": 41,
                "goalsFor": 36,
                "goalsAgainst": 13,
                "goalDifference": 23
            },

Answer №1

The platform offers an organization feature that includes the name of each entity. To access detailed information about a specific organization, you must make a separate request to the designated URL for organizations.

https://api.example.org/v2/organizations/{id}

For instance, if you want details about Organization 65

https://api.example.org/v2/organizations/65

Answer №2

You can simplify the process by creating a preestablished set of abbreviated terms and incorporating a calculated attribute within your Vue component to correspond long terms with their short counterparts.

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

Challenges encountered with Material-UI elements

Attempting to implement the http://www.material-ui.com/#/components/drawer (Docked Example) component from Material-UI in conjunction with ReactJS. An error is encountered with the "=" sign in this line: handleToggle = () => this.setState({open: !this ...

Accessing the value returned by an asynchronous function in Node.js with Electron

As I embark on a new project, my goal is to take user input, process it through a function, and then return the updated value back to the user. Despite being a novice with async functions, I've done extensive research but still can't pinpoint if ...

Issue with passing boolean parameter in Javascript not functioning properly

I have a function that contains multiple if statements, designed to execute when a parameter is true. However, I've noticed that passing false as a parameter does not seem to have any effect. Can you help me figure out what I'm doing wrong? fu ...

Utilize Ajax.ActionLink on a DIV by incorporating data from the Model

Although there are similar questions on this topic already, they do not address the specific issue of using values from the model as arguments for the controller. Make DIV containing AJAX ActionLink clickable Div as Ajax.ActionLink Take a look at the fo ...

What is the best way to include additional columns in a multiselect dropdown using jQuery select2?

I have implemented a multiselect dropdown feature using the jQuery select2 JavaScript library. The list items in this dropdown pertain to various medical drugs. I am looking to enhance this feature by adding a new column next to each selected drug, where ...

The v-model attribute is not properly passing through to the child component

I have created a custom <select> component: <!-- Select.vue --> <template> <div class="select" inheritAttrs="false"> <select v-bind="$attrs"> <slot></slot> </select ...

Placing a MongoDB query results in an increase of roughly 120MB in the total JS heap size

I'm puzzled by the fact that the heap size increases when I include a MongoDB database query in a function within my controller. Here is the code for my router: import { Router } from "express"; import profileController from '../contro ...

When working with TypeScript, it's important to note that an implicit 'any' type may occur when trying to use an expression of type 'string' to index a specific type

Currently, I'm attempting to transfer a custom hook used in Vue for handling i18n from JavaScript to TypeScript. However, I am encountering a persistent error message: An element is implicitly assigned the type 'any' due to an expression o ...

Steps to dynamically modify an HTML element within an Android WebView

https://www.bing.com/search?q=кму here I want to switch the bing icon to google I attempted : if (url == "https://www.bing.com/search?q=") { view.evaluateJavascript( ("\n"+ "wind ...

Enabling specific special characters for validation in Angular applications

How can we create a regex pattern that allows letters, numbers, and certain special characters (- and .) while disallowing others? #Code private _createModelForm(): FormGroup { return this.formBuilder.group({ propertyId: this.data.propertyId, ...

Repurpose the identical popup window

I am searching for a solution to use the same pop-up window whenever it is called. Currently, I need to submit a form into a pop-up window and it works well, except in Chrome iOS where each form submission opens a new tab/window instead of reusing the prev ...

An issue encountered with getServerSideProps in NextJS 12 is causing a HttpError stating that cookies are not iterable, leading

Currently, I have an application running smoothly on my localhost. However, when it comes to production, an unexpected error has popped up: Error: HttpError: cookies is not iterable at handleError (/usr/src/.next/server/chunks/6830.js:163:11) at sendReques ...

Vue: when switching between two instances of identical components, the view does not refresh

Within my Vue-powered UI setup, there is functionality that allows the user to switch between different content options within a specific div. Interestingly, two of these options involve utilizing instances of the same child component but with varying prop ...

The base64 code generated by the toDataURL method on the canvas appears to be incorrect

I am facing an issue with my code while using canvas to draw a cropped image with base 64. The problem is that it works perfectly on Chrome but gives me a blank image on Firefox. async function base64SquareCrop(imgbase64, size = 224) { const img = docume ...

JavaScript Filtering Techniques

Looking for a simpler way to remove an item from a list of 10 items without using arrow functions. My current method is shown below, but I'm seeking a more efficient solution. function getFilteredItems(myItems) { var items = ['item1& ...

Integrate Angular 2 into the current layout of Express framework

After generating an express structure with express-generator, I ended up with the standard setup: bin bld node_modules public routes views app.js package.json Now, I want to enhance the views and routes directories by organizing them as follows: v ...

Saving the output of a function in Javascript/NodeJS to a variable

I've been attempting to save the output of a function into a variable, but it's not working as expected. I've exhausted all my ideas and possibilities. Perhaps I'm just making a silly mistake :D I'm working with NodeJS, using expre ...

Improving React Components with Material-UI Integration

Is it possible to export a class extended from React.Component while using React and Material-UI? I need to access React variables like state within the class. If exporting the extended class is not an option, how can I still utilize state? Here is a samp ...

Starting a Vue.js app with preloaded data

I have a single file component named Foo: <template> <div> This is the main app. X is {{ x }}, y is {{ y }} </div> </template> <script> export default { data() { return { x: 'hello x' }; }, } </script> ...

Is there a way to resize SVG images without having to modify the underlying source code?

Within my Vue Single File Component, there is a prop labeled svg, which holds a string of SVG markup like <svg>...</svg>. What is the best way to render and resize this SVG content? ...