Unsplash-js do not understand the setting?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
160 views
Handle documentation unsplash.com and I do not understand the parameters of the "toJson" and "callbackUrl".

Trying to get some photos at the docks:
// the above variables are: appId, appSecret const unsplash = new Unsplash({ applicationId: appId, // variable ID secret: appSecret, // a variable with secret // callbackUrl: "{CALLBACK_URL}", this parameter is not clear to me, and took him }); /* eslint-disable */ unsplash.photos.listPhotos(2, 15, "latest") .then(toJson) // don't know what here to lay down at the docks not found .then(json => { console.log(json); });


this code throws the error: Uncaught ReferenceError: toJson is not defined

please tell me how to describe this code.

-----------------------------------------

I tried to modify the code:
const unsplash = new Unsplash({ applicationId: appId, // variable ID secret: appSecret, // a variable with secret // callbackUrl: "{CALLBACK_URL}", this parameter is not clear to me, and took him }); unsplash.photos.listPhotos(2, 15, "latest") .then(res => res.json()) .then(json => { console.log(json); });


and now another error from api unsplash: "OAuth error: The access token is invalid"error

I do not understand which token is needed, I put bearerToken: ACCESS_KEY and still this error appears... I do not understand anything at all.
by | 160 views

1 Answer

0 like 0 dislike
toJson imported
impor { toJson } from "unsplash-js";
UPD:
Here is the code of this function
function toJson(res: Object): Object { return typeof res.json === "function" ? Res. json() : res; }
by
110,608 questions
257,186 answers
0 comments
35,390 users