Skip to content

GET

The GET method requests a representation of the specified resource. Requests using GET should only be used to request data (they shouldn’t include data).

GET is considered a “safe” method because it does not alter the state of the server. It is also “idempotent”, meaning multiple identical requests should have the same effect as a single request.

When using fetch in Bun or Node.js (v18+), GET is the default method.

const response = await fetch('https://api.example.com/data');
const data = await response.json();
  • Browsers cache GET requests by default. Make sure to use appropriate cache headers (Cache-Control) to prevent stale data.
  • Do not pass sensitive info (like passwords) in the URL query string of a GET request.