Learn Frontend Concepts
Simple frontend Concepts
Fetch API using Svelte JS
Fetch API is a modern way to make HTTP requests in JavaScript. It is a promise-based API that allows you to make network requests similar to XMLHttpRequest (XHR).
APIs (Application Programming Interfaces) are typically accessed through HTTP requests. Here's a simplified explanation of how APIs are fetched:
- Identify the API : First, you need to know the endpoint of the API you want to fetch. This endpoint is usually a URL provided by the service or application offering the API.
- Choose the Appropriate HTTP Method : Depending on the action you want to
perform, you'll use one of the HTTP methods:
- GET : Retrieves data from the API.
- POST: Sends data to the API to create or update a resource.
- PUT: Sends data to the API to update a resource.
- DELETE: Deletes a resource from the API.
- And other less common methods like PATCH, OPTIONS, etc.
Here's an example of how to use the Fetch API to make a GET request to an API endpoint with Limit is equal to 3