RapidAPI Profile picture
Feb 11 โ€ข 12 tweets โ€ข 2 min read
A complete Introduction to Fetch API.

Thread ๐Ÿงต๐Ÿ‘‡๐Ÿป
Fetch is a web API that provides an interface to fetch resources across the networks.

For making a request, we have the `fetch()` method.
The fetch method is entirely based on `promises` that can be resolved to the request's response.

Before moving further, let's talk a little bit about Promises. ๐Ÿ‘‡๐Ÿป
We can say that Promise is nothing but the object that represents the result of an asynchronous call.

The result can either be successful or failure.
A Promise has three states:

Pending: Neither fulfilled nor rejected.
Resolved: Promise fulfilled.
Rejected: Promise rejected.
There are two possible scenarios when you fetch resources through an API call.

- The server will return the resource: Promise fulfilled.
- The server will throw an error: Promise rejected.
If you want to learn more about Promise, please take a look here.

developer.mozilla.org/en-US/docs/Webโ€ฆ
Now let's get back to fetch API.

Fetch takes at least one argument, i.e., the path of the resource you are interested in fetching.

Fetch API always returns a promise which will be captured by the `then()` method.

Rejected promises can be captured by the `catch()` method. fetch method.
In the above code snippet, we didn't mention the HTTP request.

If we don't specify the HTTP method, the fetch API will use GET by default.
What if we want to make POST, PUT, or DELETE requests?

The fetch method takes a second optional argument as well.
This second parameter is nothing but the `init` object.

It is mainly used to pass the HTTP method and request body, but you can pass many other things.

Let's see that in practice. ๐Ÿ‘‡๐Ÿป POST request using fetch API.
With that being said, this is pretty much it for this thread.

Follow @Rapid_API for more exclusive content.

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with RapidAPI

RapidAPI Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Rapid_API

Feb 10
Project-based learning is the way to improve your coding skills.

Use these ten excellent Flight APIs and build great projects.

Thread ๐Ÿงต๐Ÿ‘‡๐Ÿป
1๏ธโƒฃ AeroDataBox

- This API provides you with flight status, flight delays, schedules, airport, and much more.

๐Ÿ”— RapidAPI.com/aerodatabox/apโ€ฆ
2๏ธโƒฃ ADSBx Flight Sim Traffic

- Provides actual real-world traffic data use in flight simulators.

๐Ÿ”— RapidAPI.com/adsbx/api/adsbโ€ฆ
Read 12 tweets
Feb 8
What exactly is CORS.

Thread ๐Ÿงต๐Ÿ‘‡๐Ÿป
CORS is an HTTP-based mechanism that lets you request data from one URL to a different URL.
CORS stands for Cross-Origin Resource Sharing.

Half of the definition is clear by the abbreviation. CORS allows a server to share resources with browsers having different origins.
Read 20 tweets
Feb 7
These ten threads will help you improve your API development skills.

Thread ๐Ÿงต๐Ÿ‘‡๐Ÿป
Read 11 tweets
Feb 3
Let's break down the process of building a GraphQL server from scratch.

Thread ๐Ÿงต๐Ÿ‘‡๐Ÿป
Let's start with the theoretical discussion.

Quickly take a look at this thread to get started with GraphQL. ๐Ÿ‘‡๐Ÿป

We are assuming you have Node.js installed on your machine. If you haven't installed it, click on the following link and install it simply.

nodejs.org/en/
Read 20 tweets
Feb 3
What exactly is the HTTP-based system.

Thread ๐Ÿงต๐Ÿ‘‡๐Ÿป
HTTP is a communication protocol that establishes the connection between web browsers and web servers.
HTTP is entirely based on the client-server model, where the client initiates the request then waits until it receives a response from the server.
Read 19 tweets
Feb 2
What exactly is GraphQL.

Thread ๐Ÿงต๐Ÿ‘‡๐Ÿป
GraphQL is a query language that lets your client request the server to send only the required data.
GraphQL was created by developers at Facebook in 2012.

GraphQL was developed to support the complicated data structures required to show the Facebook News Feed on the mobile application.
Read 18 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

:(