Add more functions to the Utopian api npm package
New Features
What feature(s) did you add?
I have added three more functions to the npm package.
- To get post by username and permlink.
utopian.getPost = (username, permlink) => {
return new Promise((resolve, reject) => {
requestURL(ENDPOINT_POSTS + '/' + username + '/' + permlink).then((data) => {
resolve(JSON.parse(data))
}).catch((err) => reject(err))
})
}
- To get post URL by postid
utopian.getPostURL = (postID) => {
return new Promise((resolve, reject) => {
requestURL(ENDPOINT_POSTS + '/byid/' + postID).then((data) => {
resolve('https://utopian.io' + JSON.parse(data).url)
}).catch((err) => reject(err))
})
}
- To get posts by a user
utopian.getPostByAuthor = (username, options) => {
return new Promise((resolve, reject) => {
if (!options) options = {}
if (options.limit > 20 || options.limit < 1) {
options.limit = 20
}
if (options.length === 0) {
options.limit = 20
options.skip = 0
}
options.section = 'author'
options.author = username
requestURL(ENDPOINT_POSTS + '?' + encodeQueryData(options)).then((data) => {
resolve(JSON.parse(data))
}).catch((err) => reject(err))
})
}
How did you implement it/them?
I referred to the Utopian docs for checking out the endpoints to add these specific features. I have added relevant tests for these features. You can see the commits in the attached pull request.
Tests were written usng chaiJS and mochaJS and code qulity was checked by standard.
Posted on Utopian.io - Rewarding Open Source Contributors
Nice to see that my changes are still alive hehehe, nice work!
Yeah they are a important part of it!
It is a great package and it will be improving thanks to you guys
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
This is an AMAZING post! Thank you for sharing! I voted!
Thanks!
Hey @ms10398 I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x