Skip to content

halresource not resulting from a $post of a halresource #41

@gregmacbean

Description

@gregmacbean

I am using angular-hypermedia with HalResources, I have set this as the default for my HalContext.

When I do a post using the following:

provider.$linkRel('create-client', halResource).$post({ data: 'data' }).then(function(response){ 
    console.log(typeof response.data)
})

The typeof the response.data is a Resource, and not a HalResource as I expected.

Two questions:

  1. Should angular-hypermedia be updated to return a HalResource from a post when this is the expected factory.

  2. I am struggling to create a HalResource from the Resource, there seems to be some unexpected side affects, I keep getting httpPost on context undefined when using:

new halResource(createdClient._links['create-invoice'].href, myContext).$linkRel // (or $post)

The console error is :

angular.js:13645 TypeError: this.$context.httpPost is not a function
at HalResource.value (http://localhost/app/providers/jspm_packages/npm/angular-hypermedia@1.0.0/dist/hypermedia.js:934:30)

The code at location being,

$post: {value: function (data, headers, callback) {
    return this.$context.httpPost(this, data, headers, callback);
}}

Where to from here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions