Closed samijaber closed 3 years ago
Outside of the methods we don't implement, are there any breaking changes?
There's more! It's pretty much all changed. I'll need to write up a new readme of course. Biggest things:
response.json()
if the response
is valid JSON and returns that as its outputnew Unsplash()
A very quick overview of how to consume response from the new API:
const api = Unsplash({ accessKey: 'abc123' });
api.photos.get({ photoId: 'foo' }).then(result => {
if (result.type === 'error') {
console.log('error occurred: ', result.errors[0]);
} else if (result.type === 'aborted') {
console.log('fetch request aborted');
} else {
console.log('received photo: ', result.response);
}
});
One other thing I am also adding is for feed methods: the lib will automatically handle extracting the total from x-total
header and return that along with the JSON body (e.g. result.response.feed
and result.response.total
) as that's annoying manual work that any Unsplash API consumer that shows a feed will likely need for the sake of pagination.
@samijaber cool, we'll need to create an upgrade guide to go with the new README as well. Something that tells people how to go from the old methods to the new ones, and any 'gotchas'
Overview
TO-DO
Language
and string literal unions for args)url
module