Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to define api #2

Open
o-leary opened this issue Oct 9, 2019 · 1 comment
Open

Unable to define api #2

o-leary opened this issue Oct 9, 2019 · 1 comment

Comments

@o-leary
Copy link

o-leary commented Oct 9, 2019

If you have any knowledge of a working example of how to use this, please let me know!
This project looks awesome and is exactly what I've been looking for, but I can't seem to figure out when I should be able to access the api.

Resources:
Before submitting an issue, please consult our docs.

Stencil version: (run npm list @stencil/core from a terminal/cmd prompt and paste output below):
NA

 insert the output from npm list @stencil/core here

NA

I'm submitting a ... (check one with "x")
[ X] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://stencil-worldwide.slack.com

Current behavior:

Unable to define api object in scripts. I can only use the api in the console after everything has run. window.onload doesn't work, nor does including scripts in order at the end of the body tag.

Additionally after loading a page in chrome, via the console the api object appears to be at window.WordPress.api, and can be used as:

var api = window.WordPress.api;

however the instructions:

var api = document.querySelector('wordpress-api').api(); //fail as api is not a function
var api = window.WordPress; //contains an api object (api.api.posts...).

Expected behavior:

<wordpress-api> <!-- with or without base url specified -->
</wordpress-api>
<script>
var api = window.WordPress.api;

console.log(JSON.stringify(api));
</script>

  • not to be undefined.

Steps to reproduce:

Related code:

insert any relevant code here

Other information:

If you have any knowledge of a working example of how to use this, please let me know!

@o-leary
Copy link
Author

o-leary commented Oct 29, 2019

In my case I've worked around it by using settimeout delay before starting my logic.

As an aside I was easily able to extend this to work for custom post types, and it is fairly easy to embed media base64 encoded in the json, so this has been very useful for avoiding other cache limits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant