fetch-api

Catching “Failed to load resource” when using the Fetch API

只愿长相守 提交于 2021-02-08 14:43:12
问题 I'm trying to catch a bunch of errors related to the same origin policy when using the Fetch API but without any success: window.onerror = (message, file, line, col, error) => console.log(error) window.addEventListener('error', (error) => console.log(error)) try { fetch('https://www.bitstamp.net/api/ticker/').catch(e => { console.log('Caugth error:') console.log(e) console.log(JSON.stringify(e)) }) } catch (e) { console.log('try-catch') console.log(e) } The errors I want to catch only appear

How to disable ssl check in react native XMLHttpRequest API or in Fetch Api?

人走茶凉 提交于 2021-02-04 18:53:11
问题 On local testing server url have ssl certificate error so i have to disable ssl check. I have read many solutions on stackoverflow none of them helped. Problem is i can't make any change on server. So i want to know how to disable ssl check or is there any other api like fetch api or Retrofit for react native.? My fetch api code as follows fetch('https://example.com/logincheck', { method: 'post', headers: { 'Accept': 'application/json, text/plain,', 'Content-Type': 'application/json' }, body:

How to get results from Udemy Api with search?

こ雲淡風輕ζ 提交于 2021-01-29 11:30:04
问题 I want use udemy api in my website with search field in api. Udemy gives my this url: /api-2.0/courses/?search=mysql which when I use I'm getting an empty array in my results. However, when I use this url: /api-2.0/courses/ It works fine, and I'm getting 1000 rows of course details.. Please help me out with the search option, how do I make it work? <?php echo "API testing is going on\n"; function callAPI($method, $url, $data){ $curl = curl_init(); switch ($method){ case "POST": curl_setopt(

How to sum the results of a fetch using multiple functions?

白昼怎懂夜的黑 提交于 2021-01-29 06:56:46
问题 I am working with OpenWeatherMapAPI to calculate the sum of precipitation for the previous 5 days. To do this I have 5 async functions with api calls using the fetch api. The data received, that concerns me, is the hourly historic weather data spanning a 24 hour period. Full code bellow . The json response is stored to a constant (Ex. const histData1 ) where it is then iterated through to sum all of one values over that given 24 hour period. Note: humidity is used as a proof of concept

How to sum the results of a fetch using multiple functions?

一世执手 提交于 2021-01-29 06:54:49
问题 I am working with OpenWeatherMapAPI to calculate the sum of precipitation for the previous 5 days. To do this I have 5 async functions with api calls using the fetch api. The data received, that concerns me, is the hourly historic weather data spanning a 24 hour period. Full code bellow . The json response is stored to a constant (Ex. const histData1 ) where it is then iterated through to sum all of one values over that given 24 hour period. Note: humidity is used as a proof of concept

Pass data of array to react native view

百般思念 提交于 2021-01-29 05:21:05
问题 I have a function that fetch the data from backend and map over the data and then add them to array called events_data function getvals() { return fetch('http://**********/users/timetable') .then((response) => response.json()) .then((output) => { addData(output, events_data); }) .catch(error => console.log(error)) } function addData(data, data2) { data.map((d) => { data2.push({ title: d.name, startTime: genTimeBlock(d.day, d.start_time), endTime: genTimeBlock(d.day, d.end_time), location: d

Empty values when posting FormData-object via fetch-api in Internet Explorer 11

人盡茶涼 提交于 2021-01-28 08:31:11
问题 I have written a React-component which should be used for all forms in my application. When a certain button is clicked I make some validation and finally I want to post the form to the server. This is what this part currently looks like: // get what should be submitted const formData = new FormData(theForm)); // theForm is the DOM-element // post the form-data element fetch(theForm.action, { credentials: "include", //pass cookies, for authentication method: theForm.method, headers: { "Accept

Authorization against REST API throws an error: 401 (No credentials found the request.)

自作多情 提交于 2021-01-28 04:43:22
问题 I want to authorize against the HP Alm Rest API, I think this "should" work, but it does not: function performSignIn(){ let headers = new Headers(); headers.append('Content-Type', 'application/json'); headers.append('Accept', 'application/json'); headers.append('Authorization', 'Basic ' + base64.encode(username + ":" + password)); fetch(sign_in, {mode: 'no-cors', method:'POST', headers: headers}) .then(response => response.json()) .then(json => console.log(json)) .catch(error => console.log(

How do I get fetch() to POST data the same way as jQuery does?

有些话、适合烂在心里 提交于 2021-01-07 02:38:58
问题 I'm trying to remove jQuery from some code. I only use it for POST operations so I want to drop it and use fetch() instead. But I can't get fetch() to work using the same data. The php file is working OK, it is just not receiving the data This sets up the test data for both test cases below: var toPostObj = new(Object); toPostObj.action = "update+file"; toPostObj.arrays = [["2020-12-28", "23:20:56", "Trying from ztest", "9.jpg"]]; This works using jQuery: $.post('toMariaDB.php', { // url data

How do I get fetch() to POST data the same way as jQuery does?

♀尐吖头ヾ 提交于 2021-01-07 02:36:46
问题 I'm trying to remove jQuery from some code. I only use it for POST operations so I want to drop it and use fetch() instead. But I can't get fetch() to work using the same data. The php file is working OK, it is just not receiving the data This sets up the test data for both test cases below: var toPostObj = new(Object); toPostObj.action = "update+file"; toPostObj.arrays = [["2020-12-28", "23:20:56", "Trying from ztest", "9.jpg"]]; This works using jQuery: $.post('toMariaDB.php', { // url data