When dealing with ng effects, an undefined value replaces the stream observable

Currently, I am working on a flow that involves adding a new object to another object's collection. This process starts with some domain-related tasks.

Initially, I send an object to the backend and upon receiving a callback, I trigger another action in the store which should activate another effect.

In this subsequent action, I need to make another call to the backend controller with a fresh payload before completing the flow. However, trouble arises when trying to communicate with the backend, as I encounter the following error:

        from update project effect
    project.effects.ts:52 {projectId: "5980ea8390dfb5285402e18b", userId: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1273767f7b7c5265623c627e">[email protected]</a>", drawings: Array(2), projectName: "Test pro"}
    project.service.ts:37 

z update project service
    project.service.ts:38 {projectId: "5980ea8390dfb5285402e18b", userId: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2647424b4f4866515608564a">[email protected]</a>", drawings: Array(2), projectName: "Test pro"}drawings: (2) [{…}, Drawing]projectId: "5980ea8390dfb5285402e18b"projectName: "Test pro"userId: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="650401080c0b2512154b1509">[email protected]</a>"__proto__: Object
    core.es5.js:1084

 ERROR TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
        at Object.subscribeToResult (subscribeToResult.js:73)
        at 

A similar flow is successfully implemented in another part of the app, like the login feature. Here is a snippet of the code:

@Effect() addNewDrawing = this.actions
    .ofType(ProjectActions.ADD_NEW_DRAWING)
    .map(toPayload)
    .withLatestFrom(this.store.select(getProject))
    .switchMap(([payload, project] : [AddDrawingCommand, Project]) =>
      this.uploadService.upload(payload.file)
        .mergeMap((result:any) : any => {
          project.drawings.push(new Drawing(payload.drawingName, result.drawingUrl, 0));
          console.log(payload)
          console.log('------------------')
          console.log(result)
          console.log(project)
          console.log('------------------')
          return this.store.dispatch(new UpdateProject(project));
        }));

  @Effect() updateProject = this.actions
    .ofType(ProjectActions.UPDATE_PROJECT)
    .map(toPayload)
    .switchMap(payload => {
        console.log('from update project effect');
        console.log(payload);
       return this.projectService.updateProject(payload)
      }
    );

The issue seems to arise specifically during the communication with the projectService:

 updateProject(project: Project): Observable<any> {
    console.log('z update project service')
    console.log(project)
    return this.http.put(`${this.projectUrl}/${project.projectId}`, project)
      .map(response => response.json());
  }

This error is perplexing since other services function properly utilizing a similar structure.

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

Electron encountered an error while attempting to deserialize cloned data because of an invalid or unsupported version

I have developed an Angular application that is currently running as a standalone. Now, I am attempting to create an Electron app where the main functionality just involves loading the URL 'http://localhost:4200/'. However, please note that this ...

Experience the convenience of selecting multiple rows with checkboxes, while enjoying the simplicity of selecting a single row by clicking

Hey there! I'm looking to enable multiple selection using checkboxes and single selection by clicking on a row. Does anyone know how I can achieve this within the same table? Check out this link for some ideas ...

Ways to overlook compilation errors in Typescript/Electron for unreached code

I am diving into Typescript/Electron and attempting to create a text-based game. My journey began with a basic Electron application and I started implementing core logic using classes/interfaces that reference classes I have yet to implement. The snippet o ...

Encountering an error message during the installation of 'ngx-toastr' within an Angular project

Whenever I attempt to install 'ngx-toastr', I encounter an error message. Additionally, my website is being created using Bootstrap. ERROR npm ERR! Could not resolve dependency: npm ERR! peer @angular/common@">=16.0.0-0" from <a ...

Exploring the possibilities of utilizing JavaScript within TypeScript

My dynamic javascript object holds all the resources (translation strings) for my app. Here's how it is structured: var ResourceManager = (function () { function ResourceManager() { var currentLanguage = $('#activeLanguage').htm ...

What is the correct way to utilize default props in a Typescript-powered React component?

Recently diving into React, I find myself working on a basic child-component. My goal is to establish default props so that if no specific prop is provided when the component is invoked, it automatically resorts to the preset defaults. Here's what I&a ...

The state array is rejecting the value from the other array, resulting in null data being returned

I am currently attempting to extract image URLs from an HTML file input in order to send them to the backend and upload them to Cloudinary. However, I am facing an issue where despite having the imagesArr populated with images, setting the images state is ...

What is the reason behind functions evaluating to true in TypeScript?

Lately, I decided to delve into the world of TypeScript. I am intrigued by the fact that the following code snippet seems to work without any issues in this language: function f(): boolean { return false; } if ( f ) { performSomeAction(); } Desp ...

Error: The nested property of the dynamic type cannot be indexed

Within my coding project, I've devised an interface that includes various dynamic keys for API routes, along with the corresponding method and response structure. interface ApiRoutes { "auth/login": { POST: { response: { ...

How to use attributes in Angular 2 when initializing a class constructor

Is there a way to transfer attributes from a parent component to the constructor of their child components in Angular 2? The process is halfway solved, with attributes being successfully passed to the view. /client/app.ts import {Component, View, bootst ...

My Angular custom libraries are having issues with the typing paths. Can anyone help me troubleshoot what I might be doing

After successfully creating my first custom Angular library using ng-packagr, I encountered an issue where the built library contained relative paths specific to my local machine. This posed a problem as these paths would not work for anyone else trying to ...

eliminate the common elements between two arrays in typescript/javascript

I have two lists of objects, each containing two fields: let users1 = [{ name: 'barney', uuid: 'uuid3'}, { name: 'barney', uuid: 'uuid1'}, { name: 'barney', uuid: 'uuid2 ...

What is the reason behind Rollup flagging code-splitting issues even though I am not implementing code-splitting?

In my rollup.config.js file, I have only one output entry defined as follows: export default { input: './src/Index.tsx', output: { dir: './myBundle/bundle', format: 'iife', sourcemap: true, }, plugins: [ ...

Creating a backup link for a video player component in NextJs

My aim is to make sure that two video player components in a NextJS application can still access and play videos even when the application is running locally using npm run dev without an internet connection. Currently, these two components.. <HoverVi ...

To determine if two constant objects share identical structures in TypeScript, you can compare their properties

There are two theme objects available: const lightMode = { background: "white", text: { primary: "dark", secondary: "darkgrey" }, } as const const darkMode = { background: "black", text: { prim ...

Issues with Angular application navigation in live environment

While my website functions perfectly on the development server, I encounter a strange error when I publish it to production on GitHub pages. Visiting the URL (yanshuf0.github.io/portfolio) displays the page without any issues. However, if I try to access y ...

Error: TypeScript is flagging that you can only specify known properties in an object literal, and the property '...' does not exist in the type 'DeepPartial<Document>'

I've been working on building a basic controller API in NodeJS with TypeScript, but I'm encountering the error ts(2345) while trying to assign values to the model. This is my user model: import mongoose, {Schema} from 'mongoose' cons ...

Setting up Angular on an Apache2 server with an SSL certificate deployment

My apache2 server is up and running, and I decided to host an angular application on it. After building the angular application using ng build, I set up the apache configuration file and added a .htaccess file to handle internal routes. Everything was work ...

Tracking mouse movement: calculating mouse coordinates in relation to parent element

I am facing an issue with a mousemove event listener that I have set up for a div. The purpose of this listener is to track the offset between the mouse and the top of the div using event.layerY. Within this main div, there is another nested div. The prob ...

What is the best way to ensure observables in a template (using async pipe) are fully subscribed to before executing any initialization code?

I am facing an issue with my HTTP service that returns information based on a given item ID. The data is fetched using a Subject, which receives the initial data in the ngOnInit method. To display the returned data in the HTML, I utilize the async pipe. ...