Skip to content

Instantly share code, notes, and snippets.

@Shakil-Shahadat
Last active March 23, 2025 11:40
Show Gist options
  • Save Shakil-Shahadat/f52e12a8d5c26c0437857a5a45576f87 to your computer and use it in GitHub Desktop.
Save Shakil-Shahadat/f52e12a8d5c26c0437857a5a45576f87 to your computer and use it in GitHub Desktop.
✓ GET Request by Fetch
<?php
header( 'Access-Control-Allow-Origin: *' );
$received = file_get_contents( 'php://input' );
echo $received;
// Ref: https://www.php.net/manual/en/reserved.variables.post.php#125651
fetch( 'get.php' )
.then( response => response.text() )
.then( data => console.log( data ) )
.catch( error => console.error( 'Error:', error ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment