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
[Link] 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