Closed Slaestat closed 5 years ago
It may have to due with the requests being async. You may be trying to access that value before the request has completed.
If you used await
does that change your result?
var pf = new petfinder.Client(...);
var animals = await pf.animal.search();
Uncaught SyntaxError: await is only valid in async function
I got this error.
Wrap it in an async function
(async function () {
// code here
})();
As an update to this issue I don't know why, but it is now working (without the await or something like that). Thanks for your assistance.
Hi, I'm trying to implement the new version, and in an empty page the following code works for me:
var pf = new petfinder.Client({apiKey: "my-api-key", secret: "my-api-secret"});
pf.animal.search() .then(function (response) { // Do something with
response.data.animals
}) .catch(function (error) { // Handle the error });However, on full site, new petfin.... doesn't give me the token (pf.config.token). Is there anything that might be preventing the API from giving me the token ?
My apologize for the inconvenient.