by zackify · 9y ago · 0 comments
partial:
const twitter = {
register: partial`
url: https://api.twitter.com/register,
method: POST
`
}
twitter.register`
body: ${{
email: 'test@test.com',
password: 'Tester'
}}
`
Without template literals: const twitter = {
register: {
url: 'https://api.myapp.com/register',
method: 'POST',
}
}
let response = await request({
...twitter.register,
body: body,
}) const twitter = {
register: function(opts){
return request({
url: '...',
method: 'POST',
...opts
});
}
}
const resp = await twitter.register({ body });
EDIT: made it even more concise! -- back to real work :/