Using Angular 2, invoke a function within an API call

I have been attempting to incorporate a function within an API call. Despite implementing the following logic thus far, it is not functioning as intended.

code

changeStatus(id) {
    this.http.post('https://localhost:44300/api/apis/ChangeStatus/' + id, "")
        .subscribe(
            data => {
                this._data = data.json(),
                this.getAllUser();
            },
            err => this.logError(err)
        );
    }
}

Answer №1

The error is a minor one - all you need to do is substitute the , for a ; following the data.json().

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

accessing files (pdf, images) with the help of angular

I have a file stored locally on my server-side, and I need to retrieve and display it in an Angular application. Can anyone guide me on how to achieve this? I believe using blobs in Angular is necessary, but what specific parameters should I expect to rece ...

"Encountered a floating-point issue when trying to read an Excel file with

When a user uploads an Excel file that contains decimal, string, and Unicode characters, I am encountering an issue with floating point errors when reading certain decimal values. For instance, a number like 0.15 is being read as 0.150000000002 in some c ...

Tips on preventing duplicate class properties when they are declared separately from the constructor and then initialized

Imagine you have a simple ES6 class and you want to avoid redundancy by extracting constructor parameters into a separate type. For example: type BarParams = { x: string; y: number; z: boolean; }; export class Bar { public x: string; public y: n ...

Finding the current URL in React Router can be achieved by using specific methods and properties provided by

Currently, I'm diving into the world of react-redux with react-router. On one of my pages, it's crucial to know which page the user clicked on to be directed to this new page. Is there a method within react-router that allows me to access inform ...

Generating a custom type in Typescript based on specific array keys

Imagine I have a structure like this: export interface MyObject { id: number title: string } and then I create an array as shown below: const myArray: MyObject[] = [ { id: 2358, title: 'Item 1' }, { id: 85373, title: &a ...

Do we still need to configure XSRF-TOKEN on the server even when using HttpClientXsrfModule?

Would implementing the code below in app.module be sufficient to protect against XSRF/CSRF on the client side? HttpClientXsrfModule.withOptions({ cookieName: 'XSRF-TOKEN', headerName: 'X-XSRF-TOKEN' }) Alternatively, is additional ...

Can an interface be designed to have the option of containing either one property or another?

I am in need of an interface that resembles the following structure: interface EitherOr { first: string; second: number; } However, I want to make sure that this interface can only have either the property first or second. Do you think achieving this ...

What is the best way to utilize a negative glob pattern?

After our build process completes, we end up with both e2015 and es5 bundles. For example, in the dist directory, you will find files like these: /common-es2015.7765e11579e6bbced8e8.js /common-es5.7765e11579e6bbced8e8.js /custom.js We are trying to set u ...

Swap the value of a button's text using a dropdown list when clicked in VueJS with TypeScript

I have a button with a click event that opens a dropdown list. I would like for the button text to be updated and for the selected option to be removed from the dropdown list when the user makes a selection. Currently, using {{interestSortingOptions.label} ...

How can combining LINQ methods (Skip and Take) with the HttpClient.GetAsync method potentially boost efficiency and speed up performance?

I have utilized the code below to fetch the data from a JSON feed, incorporating paging techniques with the Skip and Take methods: [HttpGet("[action]")] public async Task<myPaginatedReturnedData> MyMethod(int page) { int perPage = 10; int st ...

Observable is encountering an issue where the API service is becoming undefined

Here is a glimpse into my Angular 6 Ionic 4 app - the app.component.js file. I have set up an observable to call the API service every 2 minutes to check for new notifications. The first call goes through smoothly, but then I encounter an error stating can ...

What is the reason for certain packages not being placed in the vendor folder during an Angular 2 installation?

I recently created a basic project in angular 2 using their cli. I noticed that when I use 'node install --save' for a material design project, the files are stored in both node_modules and dist/vendor directories. However, when I installed angul ...

Issues with Form Field Appearance in Angular Material 2

I've been attempting to give my form inputs a fill appearance in my application. I imported MatFormFieldModule and MatInputModule, and included appearance="fill" in my mat-form-field element. However, I'm not seeing the desired fill effect. Am I ...

Controlling the DOM with Angular 2

I am currently developing a website in Angular 2. I have successfully implemented a JQuery code that adds 2 input fields and 1 delete button when a custom button is clicked. When the user clicks on the delete button, it removes the inputs by manipulating t ...

Utilizing Lazy Loading for the search HomeComponent, which is not being utilized within the module

I'm facing an issue with Lazy Loading in Angular. I have a module called ShopCartModule that needs to be implemented using Lazy Loading. In addition to the ShopCartModule, I also have the AppModule and the CoreModule. This is my AppModule: @NgModul ...

SvgIcon is not a recognized element within the JSX syntax

Encountering a frustrating TypeScript error in an Electron React App, using MUI and MUI Icons. Although it's not halting the build process, I'm determined to resolve it as it's causing issues with defining props for icons. In a previous pro ...

Separate HTTP responses into multiple Observables

I need assistance in splitting a HTTP response into different Variables/Observables. The returned data is in JSON format: [ { "status": [ { "id": 1, "value": "active"}, { "id": 2, "value": "inactive"} ] }, { "type": [ ...

What is the proper way to validate the validity of NgModelGroup?

My form has a group of inputs that are wrapped in ngModelGroup like this: <div #myGroup="ngModelGroup" ngModelGroup="myGroup"> <input name="first" someAsyncValidator /> <input name="second" someAsyncValidator /> </div> Next, ...

Exploring JSON data in real-time

My goal here is to utilize the variables retrieved from the route to determine which blog to access from the JSON file. The JSON file consists of an array of sections, each containing an array of blogs. Although the code works flawlessly when I manually s ...

Best practices for transferring date objects between a frontend developed in JavaScript/TypeScript and a backend built in ASP.net Core 5

An exciting project I am working on involves a web application with a backend REST web API developed in ASP.net Core 5 and a frontend Angular application written in TypeScript. One of the APIs from the ASP.net backend returns an instance of a C# object de ...