We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
5 Useful Web
APIs
at
be
DevwithSaadClipboard API
This API provides access to the operating
system's clipboard. You can use it to build a
copy button to copy/paste content.
Orr coe
ete secret ets eae met
tay
await navigator.clipboard.writeText(userText);
one eC Ga ate Sec Ml tt TR
} catch (error) {
Cone aera 0
bi
oF
const readFromClipboard = async () > {
aad
One RAer CTe Le eee CMe te Ree Leto
console. log(clipboardText);
Scie asst
CeCe Css. 9
t
a
& Saad Irfan —
Soleo)LocalStorage API
It lets you store data against the website
address in the form of key/value pairs. Local
storage is limited to 5 MB.
eee ieee)
// save data in local storage
localStorage.setitem('key', '');
// get data from local storage
localStorage.getItem('key');
// remove data from local storage
localStorage.removeltem('key');
4 Saad Irfan oa
Soleo)Geolocation API
This API provides the user’s geographical
latitudes and longitudes and the accuracy to
which it is correct.
coo crear
const getCurrentLocation = () > {
navigator.geolocation.getCurrentPosition(
poeteciemnt
const coord = position.coords;
Tar Csr ans tao
Coa mercer Merete
console. Log(coord. Longitude);
in
err > {
CT CRG score essa a
in
i
CI re ate oa
timeout: 5000,
cE Su CE)
he
- Saad Irfan —
Ps STHistory API
This API lets you go back and forth between
web pages that are in your session history.
[x x ) index.js
// go back in history
window.history.back();
// go forward in history
window. history. forward();
t Saad Irfan a
Soleo)Fetch API
It is a browser API that lets you call REST
APIs or GraphQL APIs.
(rr) oe
async function callAPI() {
try {
const res = await fetch( API, {
method: '',
headers: {},
LN ay
iH
const data = await res.json();
return data;
} catch (err) {
console. log(err);
I
. Saad Irfan —
Soleo)