Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code snippet for this: https://docs.gravityview.co/article/468-rest-api (Authentication section)
<?php
$entries_url = 'https://try.gravityview.co/demo/wp-json/gravityview/v1/views/148/entries.json';
$nonce = wp_create_nonce( 'wp_rest' );
?>
<script type="text/javascript">
jQuery.ajax( {
url: <?php echo json_encode( $entries_url ); ?>,
method: 'GET',
beforeSend: function ( xhr ) {
xhr.setRequestHeader( 'X-WP-Nonce', <?php echo json_encode( $nonce ); ?> );
},
} ).done( function ( response ) {
console.log( response );
} );
</script>
<?php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment