How can i create a restangular service to update data


Hello I’m trying to create a service with restangular to update data

import {Injectable} from '@angular/core';
import {Project} from '../model/index';
import {id} from '@swimlane/ngx-datatable/release/utils';
import {Restangular} from 'ngx-restangular';

export class updateprojectService {
constructor (private restangular: Restangular) {}
update(project: Project) {
    return this.restangular.all('projects').customPUT(project,  {'id':}, undefined, {'Content-Type': undefined});

and I found this error
enter image description here

Maybe the error is to specify the id in route


You are building that put URL someway wrong, notice last part of it /[object%20Object] that’s how javascript print an object reference.

I believe it was supposed to be an id, so it would be /projects/55 for example.

Accordingly to restangular documentation, customPUT([elem, path, params, headers]), second param is a path, that’s why you are getting that problem, you are passing an object to a path

change {'id':} to if you would like to have an url like /projects/55

Answered By – Ramon Marques

Answer Checked By – Mildred Charles (AngularFixing Admin)

Leave a Reply

Your email address will not be published.