fetch

Google Maps API; “CORS header ‘Access-Control-Allow-Origin’ missing” error [duplicate]

只愿长相守 提交于 2019-12-20 06:38:22
问题 This question already has an answer here : Google Maps API: No 'Access-Control-Allow-Origin' header is present on the requested resource (1 answer) Closed 9 months ago . I'm trying to calculate the estimated travel time between two places, with the Google Maps API. I am asking for the data in the following way: const Url = 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=25.7694708,-80.259947&destinations=25.768915,-80.254659&key=' + API_KEY; try { const response = await

HTTP fetch from within Outlook add-ins

你。 提交于 2019-12-20 04:37:07
问题 I need to call an external web service so that my add-in communicates with our company's Java servlets. I tried using JavaScript's XMLHttpRequest : var http = new XMLHttpRequest(); http.open( "GET", url2, true ); http.onreadystatechange = function(){ console.log( 'Data: ' + http.responseText + '\nStatus: ' + http.status ); } and specifying Google's main site as whitelisted: <AppDomains> <AppDomain>https://www.google.com/</AppDomain> </AppDomains> to try if it works, but every time I run it

Is it possible to extract metadata from fetched url instead of canonical url?

故事扮演 提交于 2019-12-20 04:23:33
问题 I have a Facebook like that links to a page on witch I don't have complete control: I can modify the <body> but not the <head> of the page... So I tried to set the link of the like button on a new page on which I have complete control, set the opengraph metatags on this page, and set an og:url that links to the original page. But in the end Facebook tries to extract metadata from the og:url and overrides the metatags of the previous page... Is it possible to tell that I want to scrape

How do I fetch mulitiple rows using fetch(PDO::FETCH_ASSOC) with pdo?

冷暖自知 提交于 2019-12-20 04:22:13
问题 testQuery() is the method I use to get all rows from table CATEGORIES public function __construct() { self::$tdb = Database::getConnection(); } #mock query to pull results from db public function testQuery() { $queryAA = "SELECT cat_name, cat_description, cat_id FROM CATEGORIES"; $stmtAA = self::$tdb->prepare($queryAA); if ($stmtAA->execute() == true) { print("Execution was successful"); return $stmtAA->fetch(PDO::FETCH_ASSOC); } else { print("Warning statment did not successfully execute");

React “fetch()” Can “Get” but Never “Posts”

回眸只為那壹抹淺笑 提交于 2019-12-20 03:44:11
问题 I am new to the "fetch" command in React. I can use it to GET, but I have had no luck with using it to POST. I run the following simple code. onSubmit(event) { // For some reason, "fetch" is GETTING instead of POSTING. fetch('/questionare/', { method: 'post', body: JSON.stringify({greeting: "Hello"}) }).then((res) => alert(res.json)); } The content of the POST request gets processed on on the back-end by the following code. router.post('/', function(req, res, next) { res.json(req.body); });

Prefetch preview text from JavaMail Message

喜夏-厌秋 提交于 2019-12-20 02:16:06
问题 I'm using JavaMail 1.5.2 to read messages from IMAP accounts. To reduce the number of requests to the host I prefetch some message data, like From, Date, Message-ID etc.: Folder folder = store.getFolder("inbox"); folder.open(Folder.READ_ONLY); FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.ENVELOPE); fp.add(FetchProfile.Item.CONTENT_INFO); fp.add("Message-ID"); Message msgs[] = folder.getMessages(); folder.fetch(msgs,fp); However, I want to also prefetch some parts of the

Paypal UNSUPPORTED_MEDIA_TYPE

烈酒焚心 提交于 2019-12-20 02:12:24
问题 I am trying to get an access token from paypal's authorization api. When I make post request to the api I get UNSUPPORTED_MEDIA_TYPE i.e. 415 response. Below is the snippet that I used. const auth = await fetch(PAYPAL_OAUTH_API, { method: 'post', headers: { 'Content-Type': 'application/json', 'Authorization': `Basic ${ basicAuth }` }, body: JSON.stringify({"grant_type": "client_credentials"}) }); 回答1: I have fixed my issue by setting Content-Type to application/x-www-form-urlencoded . My

Why are these fetch methods asynchronous?

帅比萌擦擦* 提交于 2019-12-19 23:17:20
问题 Fetch is the new Promise-based API for making network requests: fetch('https://www.everythingisawesome.com/') .then(response => console.log('status: ', response.status)); This makes sense to me - when we initiate a network call, we return a Promise which lets our thread carry on with other business. When the response is available, the code inside the Promise executes. However, if I'm interested in the payload of the response, I do so via methods of the response, not properties: arrayBuffer()

WebAudio streaming with fetch : DOMException: Unable to decode audio data

佐手、 提交于 2019-12-19 10:03:30
问题 I'm trying to play an infinite stream coming from the fetch API using Chrome 51. (a webcam audio stream as Microsoft PCM, 16 bit, mono 11025 Hz) The code works almost OK with mp3s files, except some glitches, but it does not work at all with wav files for some reason i get "DOMException: Unable to decode audio data" The code is adapted from this answer Choppy/inaudible playback with chunked audio through Web Audio API Any idea if its possible to make it work with WAV streams ? function play

Using Axios GET with Authorization Header in React-Native App

痞子三分冷 提交于 2019-12-18 11:10:11
问题 I'm trying to use axios for a GET request with an API which requires an Authorization header. My current code: const AuthStr = 'Bearer ' + USER_TOKEN; where USER_TOKEN is the access token needed. This string concatenation may be the issue as if I post this as AuthStr = 'Bearer 41839y750138-391' , the following GET request works and returns the data I'm after. axios.get(URL, { 'headers': { 'Authorization': AuthStr } }) .then((response => { console.log(response.data); }) .catch((error) => {