G
G
gooseNjuice()2022-04-06 13:43:01
API
gooseNjuice(), 2022-04-06 13:43:01

Why am I getting different responses for the same query?

So, I send a GET request to Postman - " https://pool.apk.aptoide.com/randomy/ozgurcrs-dgs-... "
which returns me 200 OK
Then, I copy the code that Postman generated for me and I add it to my application (just create-react-app with a button that sends a request on click):

var requestOptions = {
  method: 'GET',
  redirect: 'follow'
};

fetch("https://pool.apk.aptoide.com/randomy/ozgurcrs-dgs-1-42117761-5ee6c3cdf6f9d6cf95ba7e5a2ebed6b3.apk", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

And when I send this request through my application, I get this error in Firefox:
error TypeError: NetworkError when attempting to fetch resource.

Or two of these in Chrome:
Access to fetch at ' https://pool.apk.aptoide.com/randomy/ozgurcrs-dgs-... ' from origin ' localhost:3000 ' has been blocked by CORS policy: No 'Access-Control-Allow-Origin ' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
App.js:15 GET https://pool.apk.aptoide.com/randomy/ozgurcrs-dgs-... net::ERR_FAILED 200
clickHandler @ App.js:15
callCallback @ react-dom.development.js:4157
invokeGuardedCallbackDev @ react-dom.development.js:4206
invokeGuardedCallback @ react-dom.development.js:4270
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:
executeDispatch @ react-dom.development.js:9011
processDispatchQueueItemsInOrder @ react-dom.development.js:9043
processDispatchQueue @ react-dom.development.js:9056
dispatchEventsForPlugins @ react-dom.development.js:9067
(anonymous) @ react- dom.development.js:9258
batchedUpdates$1 @ react-dom.development.js:25979
batchedUpdates @ react-dom.development.js:3984
dispatchEventForPluginEventSystem @ react-dom.development.js:9257
dispatchEvent @ react-dom.development.js :6435
dispatchDiscreteEvent @ react-dom.development.js:6410
App.js:15 error TypeError: Failed to fetch
at clickHandler (App.js:15:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:4157: one)
at Object.invokeGuardedCallbackDev (react-dom.development.js:4206:1)
at invokeGuardedCallback (react-dom.development.js:4270:1)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4284:1)
at executeDispatch( react-dom.development.js:9011:1)
at processDispatchQueueItemsInOrder (react-dom.development.js:9043:1)
at processDispatchQueue (react-dom.development.js:9056:1)
at dispatchEventsForPlugins (react-dom.development .js:9067:1)
at react-dom.development.js:9258:1


Why is this happening? CORS can be required when the application is running on localhost?
ws75.aptoide.com/api/7/apps/search?info=1 there is no useful information in the API documentation

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2022-04-06
@vabka

CORS can be required when the application is running on localhost?

Yes they can. CORS is handled by the browser.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question