Skip to main content

MAKE HTTP REQUEST IN Java Script | codes

 You can make an HTTP request in JavaScript using the XMLHttpRequest object or the fetch API.

Using XMLHttpRequest:

javascript
const xhr = new XMLHttpRequest(); xhr.open('GET', 'https://example.com/api/data', true); xhr.onload = function() { if (xhr.status === 200) { const response = JSON.parse(xhr.responseText); console.log(response); } }; xhr.onerror = function() { console.error('Request error'); }; xhr.send();

Using fetch:

javascript
fetch('https://example.com/api/data') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Fetch error:', error));

Both methods allow you to send requests and handle responses, but the fetch API is newer and more streamlined, while XMLHttpRequest is more versatile and supports features like aborting a request.

Comments

Popular posts from this blog

Download gta 5 highly compressed free download pc no survey

Grand Theft Auto V (GTA 5), for PC, download for pc, full version game, full pc game, Compressed , RIp Version How to download  Gta 5 highly compressed free download no survey GTA 5 for the Popular Game! You can download it easily. GTA 5 Action Full Game! Kalyan result Let me tell you how you can download GTA 5 highly compressed game? First! Go to this website. Search on GTA 5! Click call first post.   After that, go down. After that download all the parts of gta5. To extract the file after downloading. Enter this password Thank you! And enjoy! Note:- open website at your own risk Also read :-   Download Radhe Movie कोरोना के कारण फंगल संक्रमण Gta 5 download apk Gta 4 Download for pc नए कोविड स्ट्रेन लक्षण मूल से अलग कैसे हैं Karma Book by Sadhguru वैक्सीन के दोनों डोज लगे हों तो भी कोरोना हो सकता है Coronavirus nibandh in hindi  Best Cryptocurrency to invest  कोरोना वायरस से बचाव हेतु सुझाव Three antibiotics drugs    what is satta game ...

वैक्सीन के दोनों डोज लगे हों तो भी कोरोना हो सकता है, लेकिन गंभीर लक्षणों की आशंका 100% तक कम; संक्रमण से मौत नहीं होगी

कुछ लोगों को दूसरे डोज के बाद भी कोरोना हो रहा है। यह कैसे संभव है?  वैक्सीनेशन से जुड़ी तमाम भ्रांतियों और सवालों पर दैनिक भास्कर ने इंदौर के महात्मा गांधी मेमो. हॉस्पिटल में मेडिसिन विभाग के प्रोफेसर डॉ. वीपी पांडे और शेल्बी ग्रुप ऑफ हॉस्पिटल्स के कंसल्टिंग फिजिशयन डॉ. अजय परीख से बात की। जानिए क्या कहते हैं विशेषज्ञ... वैक्सीन कोरोना को पूरी तरह रोक देगी या कोरोना होने पर उसके असर को कम करेगी? डॉ. अजय परीखः वैक्सीन कोरोना होने पर उसके असर को कम कर देगी। यह शील्ड है यानी कवच। वह सर्दी-जुकाम रह जाएगा। डॉ. वीपी पांडेः वैक्सीन की इफेक्टिवनेस या एफिकेसी बताई जाती है कि वैक्सीन 84% या 91% एफिकेसी रखती है। यानी उन 84% या 91% लोगों में संक्रमण नहीं होगा। इसका मतलब बचे हुए 16% या 9% लोगों को इन्फेक्शन हो सकता है। अभी तक के रिसर्च के मुताबिक रोग की गंभीरता को कम करने में वैक्सीन 100% तक इफेक्टिव है, मृत्यु को 100% रोक सकती है। लोगों को वैक्सीन का पहला डोज लगाने के बाद भी कोरोना हो रहा है। ऐसा क्यों? डॉ. अजय परीखः वैक्सीन का पहला डोज लेते हैं तो वह शरीर को बताता है कि यह वायरस है, जो आपक...