0% found this document useful (0 votes)
4 views

ClassNotes JS13

The Fetch API allows for sending and receiving resources using Request and Response objects, primarily through the fetch() method. It supports both GET requests for retrieving data and POST requests for sending data, with JSON being a common format for data exchange. Additionally, it handles HTTP response status codes and headers that provide information about the response.

Uploaded by

Raj Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

ClassNotes JS13

The Fetch API allows for sending and receiving resources using Request and Response objects, primarily through the fetch() method. It supports both GET requests for retrieving data and POST requests for sending data, with JSON being a common format for data exchange. Additionally, it handles HTTP response status codes and headers that provide information about the response.

Uploaded by

Raj Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

fetch API Application programming interface

e
The Fetch API provides an interface for fetching (sending/receiving) resources.

lleg
o
It uses Request and Response objects.

na C
The fetch() method is used to fetch a resource (data).

Ap
let promise = fetch( url , [options] )
agar koi bhi options nhi die to wo ek get request ko fetch karta
hai.jab bas data receive krna h data ko kuch bhejna nahi hai
Understanding Terms

e
network ko kch request bhej rhe aur kuch response aa rha that is
AJAX is Asynchronous JS & XML

g
using ajax

olle
JSON is JavaScript Object Notation

na C
p
json() method : returns a second promise that resolves with the result of parsing the

A
response body text as JSON. (Input is JSON, output is JS object)

response(JSON) is converted to JS object using json() method


Requests & Response

e
HTTP Verbs

g
Hypertext Transfer Protocol

Response Status Code

olle
C
Http response status codes . various types

a
of errors 404 500 etc. on mdn docx

Apn
*HTTP response headers also contain details about the
responses, such as content type, HTTP status code etc.
header contains some addn info jo
shyd response ke sath aa rhi hai

Post request is used when we have to send some data.


Get requets is used when we have to get some data
Homework Task

e
Sending POST Request

lleg
Co
fetch(url,options)

pna
A

You might also like