Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i want to change PUT request target #10

Closed
ghost opened this issue May 1, 2016 · 4 comments
Closed

i want to change PUT request target #10

ghost opened this issue May 1, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented May 1, 2016

i used http://www.django-rest-framework.org/

 // Will make PUT request to https://domain.net/api/users/1
            // with stringify json data in the body
            this.userRes.update({id: 1, firstName: 'John', lastName: 'Smith'})
                .$observable
                .subscribe(
                    res => console.log(res),
                    err => console.log('Err', err)
                );

i want change request to https://domain.net/api/users/ , not https://domain.net/api/users/1

could you help me ?

@ghost ghost changed the title this.userRes.update 500 error i want to change PUT request target May 1, 2016
@troyanskiy
Copy link
Owner

Please provide full code of you UserRes class.

@ghost
Copy link
Author

ghost commented May 2, 2016

// Import necessary staff
import {Resource, ResourceParams} from "ng2-resource-rest";
import {Injectable} from "angular2/core";


// Make it Injectable
@Injectable()

// Decorate the your resource class
@ResourceParams({
    // Url to api
    url: 'https://domain.net/api',
    // Api path
    path: '/users/{id}'
})
export class UserRes extends Resource {}

@troyanskiy
Copy link
Owner

Please read docs before creating issues like that.
That is described there.
Anyway, you need to overwrite update method or create your own.

// Import necessary staff
import {Resource, ResourceParams, ResourceAction, ResourceResult} from "ng2-resource-rest";
import {Injectable} from "angular2/core";
import {RequestMethod} from "angular2/http";


// Make it Injectable
@Injectable()

// Decorate the your resource class
@ResourceParams({
    // Url to api
    url: 'https://domain.net/api',
    // Api path
    path: '/users/{id}'
})
export class UserRes extends Resource {
     @ResourceAction({
        method: RequestMethod.Put,
        path: '/users'
    })
    update(data:any, callback?:Function): ResourceResult { return null; }


     @ResourceAction({
        method: RequestMethod.Put,
        path: '/users'
    })
    myUpdate(data:any, callback?:Function): ResourceResult { return null; }
}

@ghost
Copy link
Author

ghost commented May 2, 2016

thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant