0% found this document useful (0 votes)
9 views2 pages

JavaScript Fetch and Geolocation APIs

The document explains the concept of APIs, specifically focusing on the fetch function in JavaScript, which retrieves data from a specified URL and processes it as JSON. It also covers the Geolocation API, detailing its three main functions: getCurrentPosition, watchPosition, and clearWatch, along with examples of how to implement these functionalities. The document provides practical code snippets demonstrating the use of both the fetch and Geolocation APIs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

JavaScript Fetch and Geolocation APIs

The document explains the concept of APIs, specifically focusing on the fetch function in JavaScript, which retrieves data from a specified URL and processes it as JSON. It also covers the Geolocation API, detailing its three main functions: getCurrentPosition, watchPosition, and clearWatch, along with examples of how to implement these functionalities. The document provides practical code snippets demonstrating the use of both the fetch and Geolocation APIs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Api:

---
Api stands for application programming interface.

fetch:
------
fetch is a predefine function in js,this fetch function having an argument like a
link : [Link] after convert into the json() then we can execute the data in our
loca system.

Ex:
---
fetch('[Link]
// [Link](R1)
[Link]((x)=>{
let p=[Link]('p')
[Link]=[Link]
[Link](p)
})
})

Ex:
---
fetch('[Link]
// [Link](R1)
[Link]((x)=>{
// [Link]([Link])
// if ([Link] == )
let l1=[Link]('li')
[Link]=[Link]
[Link](l1)
})

})

geolocation api:
----------------
geolocation is a api keyword which is getting from the navigator. using this
geolocation api we can work with a three function.

->getCurrentPosition :we can acces the currect position longitude and lagitude.
->watchPosition :we can watch the position if there is any changes will be
happend.
->clearWatch :clear all the position from the present location, unable to
watch the positions.

Ex:
---
if([Link]){
[Link]((position)=>{

[Link]('latitude :',[Link])

[Link]('longitude :',[Link])
},(error)=>{
[Link]([Link])

})
}

Ex:
---
if([Link]){
[Link]((position)=>{

[Link]('latitude :',[Link])

[Link]('longitude :',[Link])
},(error)=>{
[Link]([Link])

})
}

Ex:
---
if([Link]){
let watch=[Link]((position)=>{

[Link]('latitude :',[Link])

[Link]('longitude :',[Link])
},(error)=>{
[Link]([Link])

})
[Link](watch)
}

You might also like