Using REST API with JSONP and pretty permalinks disabled
-
I am using the WP REST API with WPv4.8 with pretty permalinks disabled (security reasons). I can successfully do a GET request to the posts object like so:
https://url/blogs/usernamehere/?rest_route=/wp/v2/posts
And, I can do a successful JSONP callback with pretty permalinks enabled. However, when pretty permalinks are disabled, I can not do a successful GET request with JSONP. I get a 404 NOT FOUND when using JSONP callback like so:
My callback function:
jsonp.js file:
var posts; function receiveData(data){ posts = data; }
My HTML index file:
<script src="jsonp.js></script> <script src="https://url/blogs/usernamehere/?rest_route=/wp/v2/posts?_jsonp=receiveData"></script>
Has anyone tested using JSONP with pretty permalinks disabled? Any clues on what I am doing wrong ? Thank you
[Moderator note: First URL corrected per OP’s second post. Second post archived so OP remains on no replies view.]
- The topic ‘Using REST API with JSONP and pretty permalinks disabled’ is closed to new replies.