Category : fetch-api

Spent the whole morning to manage simple cross origin request with fetch to php server js side return fetch(serverPath + ‘categories’, { mode: ‘no-cors’ }) .then(r => { if (r.ok) return r.json() alert(r.status) }) php side <?php header(‘Access-Control-Allow-Origin: *’); header(‘Access-Control-Allow-Methods: POST, GET, OPTIONS’); header(‘Access-Control-Allow-Headers: *’); header(‘Access-Control-Max-Age: 86400’); echo json_encode([[ ‘id’ => 1, ‘name’ => ‘test’ ..

Read more

There are many similar questions around this topic but I could not find what I am missing in this fetch api request. could you someone help me to overcome this error ? how to set the http status ok in fetch api request. I understand we need to set this for OPTIONS method but not ..

Read more

I have an Excel add-in which connects to a business system via a URL provided by the user. The add-in prompts the user for an ID and Password, and when successfully logged in, receives a token from the business system, that is included in any future calls to the business system api. The token is ..

Read more

I’m trying to write a chrome extension that needs to intercept HTTP response data. I was looking at a similar extension but I couldn’t understand the following part of the code: (function() { ‘use strict’; var oldXHR, stateChangeHandler, prop; oldXHR = window.XMLHttpRequest; stateChangeHandler = function (evt) { const constantMock = window.fetch; window.fetch = function() { ..

Read more