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

Option to change bodyAttr #56

Closed
sximba opened this issue Jun 15, 2017 · 4 comments · Fixed by #114
Closed

Option to change bodyAttr #56

sximba opened this issue Jun 15, 2017 · 4 comments · Fixed by #114

Comments

@sximba
Copy link
Contributor

sximba commented Jun 15, 2017

Hi @tulios

Prior to version 2.0.0 we had something like this:
Mappersmith.forge(Manifest, Gateway, "data")

Is there a way to achieve the same (pass a custom bodyAttr) on version >= 2.0.0?

PS: If possible, can you put together a minimal migration guide?

@tulios
Copy link
Owner

tulios commented Jun 15, 2017

Yes :)

You can take a look here (https://github.com/tulios/mappersmith#body), but in a nutshell you can use the bodyAttr when defining your methods, example:

// ...
{
  create: { method: 'post', path: '/blogs', bodyAttr: 'payload' }
}
// ...

client.Blog.create({
  payload: {
    title: 'Title',
    tags: ['party', 'launch']
  }
})

@sximba
Copy link
Contributor Author

sximba commented Jun 15, 2017

Is it not possible to make it a global config like before?

@tulios
Copy link
Owner

tulios commented Jun 15, 2017

Currently it's not possible, is it something you would like to have?

@sximba
Copy link
Contributor Author

sximba commented Jun 15, 2017

Yeah. It would be nice to have some of the resource attributes i.e bodyAttr, headersAttr and authAttr configurable at a higher level than resource definition, like host.

My thinking behind this is that they are less likely to change than path and method. So that something like the following is possible:

const client = forge({
  host: 'https://status.github.com',
  bodyAttr: 'data',
  headersAttr: 'h',
  resources: {
    User: {
      all: { path: '/users' }
    }
  }
})

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

Successfully merging a pull request may close this issue.

2 participants