"Patience is key when waiting for a response from an Angular

I've come across several similar posts with the same title, but none of them address my specific use case.
In my situation, I have an array of items with properties that can be ('serials','macs','null'). For each type of property, a different API endpoint needs to be called. Additionally, within the 'model' property, there is an array of models that also need to be sent individually. I understand this may not be the most efficient way to handle this, but unfortunately, I inherited this messy design and am not responsible for it.
the service code :

  createDevice(data: Device) {
    return this.http.post('somewhere', data, {
      headers: this.httpHeader,
    });
  }

component code:

 this.sourceDataSet.forEach(item=>{

 if(item.serials){
   item.serials.forEach(serial=>{
  //create it

  })
  
  }
 else if(item.macs){

  item.macs.forEach(serial=>{
  //create it

  })

  }
else{

  // create it 

  } 
})

The issue is that other properties may be affected by these actions, which is something I want to avoid. Is there a more elegant solution for this problem?

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

Deactivating checkboxes once the maximum selection has been made through jquery

I need assistance with my jQuery code that is supposed to disable checkboxes in a multidimensional array after reaching the maximum number of selections. However, I am having trouble identifying the issue within the code. Any guidance would be greatly ap ...

Banish document in Brunch regex pattern

How can I exclude the file mapdata.coffee located in the view folder from the joinTo configuration in Brunch? This is what I attempted: 'javascripts/app.js':/^app(\/|\\)(?!(tests|store-test|views\/mapdata.coffee))/ What am ...

What could be causing the TypeError in my pg-query result?

In the process of creating a node function to add a user to a PostgreSQL database, I am utilizing node.js, pg, and pg-query for communication between the application and the database. Prior to inserting a new record, I am attempting to verify that the ema ...

Tips for showing ng-repeat items solely when filters are applied by the user

Is there a way to only display elements when a user uses a filter? For instance: $scope.elements = [{name : 'Pablo', age : 23}, {name : 'Franco', age : 98}]; <input type="text" ng-model="searchText" /> <div ng-repeat="elemen ...

What is the best way to smoothly enlarge a div as new content is introduced?

Is there a way to smoothly expand a div when new content is added? const [render, setRender] = useState(false) const showHide= () => { setRender(!render) } return ( <div className="container"> <h1>TEST ...

What happens when the "get" keyword is added to methods in Angular 2?

My observation is that I can create get methods with or without the "get" keyword preceding the method name. The materials I have read indicate that this is for retrieving property values, so there is no need to invoke the get method; instead, one can us ...

Implementing interactive functionality to expanding lists in Vuetify.js

Can someone help me figure out how to add an active state for lists in Vuetify? I want the lists to have a primary background color, just like they show in their documentation: This is my code: <template> <v-navigation-drawer width="300px& ...

Using JQuery Datepicker with an icon and custom format in ASP.NET

I am looking to incorporate jQuery into my Textbox. Specifically, I would like to use the Datepicker with the format yyyy-mm-dd and include an Icon as well. <script> $( "#txtVon" ).datepicker({ showOn: "button", buttonImage: "ima ...

How can you extract a string from an array?

When attempting to loop through a string array in TypeScript, I encounter an error stating that foreach is not a function. What is the correct way to implement this in TypeScript? Here is my code in main.ts: content = ["renewal", "payments"] If I use a ...

Loop through every item in Typescript

I am currently working with the following data structure: product: { id: "id1", title: "ProductName 1", additionalDetails: { o1: { id: "pp1", label: "Text", content: [{ id: "ppp1", label: "Tetetet" ...

Receiving errors when sending XML via an AJAX request is a common issue

I'm encountering an issue with handling the response from a specific web service through my XML request. Despite the response appearing as expected in my browser's network tab, the error callback in my JavaScript code is triggering, treating it a ...

Obtaining Asynchronous JavaScript responses with Selenium Webdriver

We recently integrated an asynchronous JavaScript call into our website. I am currently working on configuring Selenium Webdriver to pause and wait for a response from this particular call. The event listener code snippet is as follows: $(document).on("a ...

I'm having trouble loading my Google Maps widget. Everything was functioning flawlessly until I attempted to hide it using the .hide function

After successfully implementing a Google Maps widget, I encountered an issue when trying to toggle its visibility using jQuery. Despite clicking on a div element to reveal the widget, the map fails to load inside the designated container. It seems as tho ...

Using React to make an API call without utilizing hooks

Hello, I am currently working on developing a webpart using SharePoint and React. However, I am facing some issues with fetching data from a simple API. export default class Testing100 extends React.Component<ITesting100Props, {}> { constructor(p ...

Stopping npm private organization from releasing public packages

Is there a method to restrict the publication of public packages within an npm organization? It appears that this scenario would often arise (ensuring that no member of an organization accidentally publishes a package as public when it should be private b ...

The match() function does not seem to be functioning properly on iOS and Android devices, as it consistently returns a

Currently, I have a loop set up to go through a list of names in order to check if the user's search query (stored as variable "s") matches any of the names. This loop functions perfectly on desktops and laptops, but unfortunately, it does not work on ...

Optimized Handlebars template using RequireJS

I recently precompiled a handlebars template manually and saved it as "testTemplate.handlebars." Now, in my code using requireJS and Backbone, I have the following function: define(['text!../templates/testTemplate.handlebars' ],function( ...

Tips for transferring a calculated value from a child component to a parent component in ReactJs

In my current project, I am faced with the challenge of passing a calculated value from a child component back to its parent. The child component is designed to utilize various user inputs to compute a single value that needs to be returned to the parent. ...

Execute an ajax request when the button is clicked

I am facing an issue with a button that is supposed to trigger a function involving an ajax call and other tasks. Despite setting the button's id for a click function, I am unable to generate any response upon clicking. $.ajax({ type: "GET", ...

Leveraging Angular js for performing operations in Putty

At the moment, we depend on Putty for connecting to the app server and checking logs. I am looking for a solution that would allow me to automate this process using angular js. Is it possible to send commands from my angular js or any other client-side a ...