UNPKG

@sno2/pex

Version:

An unofficial promise-based Pexels API wrapper with top-notch TypeScript support.

3 lines (2 loc) 1.47 kB
import e from"axios";var t=0;function r(e){return"__private_"+t+++"_"+e}function o(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var i=r("opts"),s=r("axios");class n{constructor(t){Object.defineProperty(this,i,{writable:!0,value:void 0}),Object.defineProperty(this,s,{writable:!0,value:void 0}),o(this,i)[i]=t,o(this,s)[s]=e.create({baseURL:"https://api.pexels.com",headers:{Authorization:o(this,i)[i].key}})}getPhoto(e){try{return Promise.resolve(o(this,s)[s].get(`/v1/photos${e.id}`)).then(function(e){return e.data})}catch(e){return Promise.reject(e)}}getPhotos(e){try{return Promise.resolve(o(this,s)[s].get("/v1/search",{params:e})).then(function(e){return e.data})}catch(e){return Promise.reject(e)}}getCuratedPhotos(e){try{return Promise.resolve(o(this,s)[s].get("/v1/curated",{params:e})).then(function(e){return e.data})}catch(e){return Promise.reject(e)}}getVideo(e){try{return Promise.resolve(o(this,s)[s].get(`/videos/${e.id}`)).then(function(e){return e.data})}catch(e){return Promise.reject(e)}}getVideos(e){try{return Promise.resolve(o(this,s)[s].get("/videos/search",{params:e})).then(function(e){return e.data})}catch(e){return Promise.reject(e)}}getPopularVideos(e){try{return Promise.resolve(o(this,s)[s].get("/videos/popular",{params:e})).then(function(e){return e.data})}catch(e){return Promise.reject(e)}}}export{n as Pex}; //# sourceMappingURL=index.module.js.map