Error in Ionic 3 Framework: Typescript Error - The function was expecting anywhere between 0 to 2 arguments, but received 3 instead

I am currently working on an http request using the Ionic Native HTTP plugin, but I encountered the following error:

Error
[ts] Expected 0-2 arguments, but got 3.

Here is the specific Http call that I am trying to make:


getAcknowledgmentRequest(ssoId, alertType) {

    var url = this.globals.getUrl() + "receive_orderM";
    var body = JSON.stringify({ sso_id: ssoId, alert_type: alertType });    

    let bearer = 'Bearer ' + this.globals.getAccess();
    let headers = { 'Accept': 'application/json' , 'Authorization': bearer };

    return this.http.post(url,body,headers).then(
      (resp: HTTPResponse) => {
         return resp.data;
     })
     .catch((error: any) => {
        console.log(error);
     });
}

Additionally, here is the method where I call my service:

this.messageService.getAcknowledgmentRequest(sso_id,alertType).then(
        (response: any) =>{   
            this.responseData = data;
            this.orders = this.responseData ;
            if (this.orders.length == 0) {
              this.showMessage = true;
            }
            loading.dismiss();         
        })
        .catch(error => {
            Console.log(error);
        })

Answer â„–1

In my opinion, the appropriate structure for a post should be an object and not a string:

var data = JSON.stringify({ user_id: userId, message: msg });  

Instead, it should look like this:

var data = { user_id: userId, message: msg };

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

Error occurs when attempting to test both boolean and number data within an ngIf statement

In the scenario where I am working with a template that includes a boolean called readOnly and an array known as arrayOfStuff: <span *ngIf="!readOnly && arrayOfStuff && arrayOfStuff.length">Hey</span> When running eitherng bui ...

What is the best method for implementing intersection types within an angular template?

While working with intersection types in an Angular template, I faced a challenge. In my component's TypeScript file, I defined the following input: export class ExampleClassComponent { ... @Input() items: Array<InfoItem> | Array<InfoItem ...

Limitations of typescript generics

Sorry for the unclear title, I'm struggling to phrase this question concisely! I'm attempting to create a class: class Stream<Template<T,K,I>> I realize this is not the correct syntax. So far, I have... class Stream<T extends ob ...

Encountering problem with loading Angular2 RC1 - SyntaxError: Found unexpected token "<"

After transitioning my application from Angular 2 beta 18 to Angular2 RC1, I made changes to imports and corrected syntax errors. However, I am now encountering an error during the app loading process. Additionally, the Angular2 quickstart is not functioni ...

Utilizing next.config.js in Next.js TypeScript for personalized settings

As a newcomer to nextjs typescript, I am currently exploring the usage of next.config.js in my nextjs typescript project for custom configurations. Here is an example of what I have attempted: const path = require('path') module.exports = { sa ...

Linking children to their parents in a mat tree structure

I'm looking to create a mat tree based on the provided diagram. https://i.sstatic.net/cTY2w.png So far, I've managed to design the icons and boxes, but I'm struggling with drawing the connecting lines. Can anyone assist me with this part? I ...

Error during Ng 16 upgrade - npm ERR! Peer dependency conflict found: @angular/[email protected]

I am currently in the process of upgrading my Angular version from 11 to 16. While this Angular documentation has been quite helpful, I am encountering various errors and challenges. Let me provide you with the versions I am working with: Angular CLI: 11. ...

Caution: Npm Angular alert during package installation

I keep encountering npm warnings while attempting to install packages: $ npm install npm WARN @angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ee8d81839e87828b9cc38d8287aedfdec0dec0dc">[email protected]</a> ...

Unusual elective attributes found in TypeScript classes

Out of the blue, I started getting a ts2322 error with the code below. Everything was working fine in the Typescript playground. I have reviewed it multiple times but can't seem to find any issues. What could be causing the problem? The software ver ...

Disabling the submission button in the absence of any input or data

I am currently experiencing an issue where the submit button is active and displays an error message when clicked without any data. I would like to rectify this situation by disabling the submit button until there is valid data input. < ...

The mandatory input field property is malfunctioning, and the color of the input field remains unchanged

<div class="container"> <h1>Register Form</h1> <form> <div class="form-group" > <label for="name">Full Name</label> <input type="text" class="form-control" [ngClass]="{& ...

Endless loop in RxJS when updating the Ngrx store

// Custom Component HTML <button (click)="reRoute(1)">Select</button> // Custom Component TypeScript reRoute(id: any) { this.store.select(fromStore.getBasketEntities).subscribe(data => { const dynamicUrl = id + '_' + Object ...

Encountering unspecified values when subscribing to a BehaviorSubject and receiving it as an Observable

My goal is to display the name of the currently logged-in user in the header of my application. However, I encountered an issue where upon refreshing the page, the value would be lost due to SPA behavior (even though the data is stored in local storage). T ...

Guide on implementing the button tag outside of a form while utilizing the form.invalid function within a template-driven form

<form #documentEditForm="ngForm" id="ngForm" (ngSubmit)="onDocSubmit()" > <div class="form-group"> <label for="DOC_NAME">DOC_NAME</label> <input ...

Constructor caching leading to the error message: "The property '...' does not have an initializer and is not definitely assigned in the constructor."

Whenever I work on projects, I tend to create classes with constructors that cache the objects they generate. This way, if the constructor is called with the same parameters multiple times, it will return the same instance rather than creating redundant in ...

The process of inserting data into MongoDB using Mongoose with TypeScript

Recently, I encountered an issue while trying to insert data into a MongoDB database using a TypeScript code for a CRUD API. The problem arises when using the mongoose package specifically designed for MongoDB integration. import Transaction from 'mon ...

The error message "Property 'listingSub$' is not initialized in the constructor and is not definitely assigned" needs to be addressed and fixed in the code

import { Subscription } from "rxjs"; @Component({ selector: 'app-listing-detail', templateUrl: './listing-detail.component.html', styleUrls: ['./listing-detail.component.scss'] }) export class ListingDetailCo ...

Vue 3 with Typescript - encountering a property that does not exist on the specified type error

I'm currently working on populating a component with leads fetched from an API. In my setup, I have a LeadService file and a Vue template file. The challenge I'm encountering is related to using an async call in my template file. Although the cal ...

The child component is failing to detect changes, consider using alternative methods like ngDoCheck to update the component's value

Within the childComponent @input() method, I am sending an array of objects where each object has 3 properties: name, id, and selected (boolean). My goal is to change only the selected property in the array and pass it to the child component for rendering. ...

Return either a wrapped or base type based on the condition

I am a beginner in TypeScript and I'm struggling to find the right combination of search terms to solve my issue. It seems like using a type condition could be helpful, but I still need to grasp how they function. My goal is to pass a function that p ...