-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Closed
Labels
Platform: AndroidAndroid applications.Android applications.Ran CommandsOne of our bots successfully processed a command.One of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.Type: QuestionIssues that are actually questions and not bug reports.Issues that are actually questions and not bug reports.🌐NetworkingRelated to a networking API.Related to a networking API.
Description
React-Native Framework
I always get the same error and have nothing wrong on the server side, the problem is in the fetch method.
can anybody help me ?
My code (Api.js):
const API_URL = 'https://10.0.0.9';
const API_PORT = 3000;
const API_QUERY = '?data=';
const API_ERR_ARG = { error: 'unsupported argument type' };
/**
* HTTP Communication (API)
*/
async function getData(dataType, callback, callbackErr) {
if(typeof(dataType) !== 'string') return API_ERR_ARG;
try {
// address: https://localhost:3000?data=argument
const response = await fetch(`${API_URL}:${API_PORT}${API_QUERY}${dataType}`);
const responseJson = await response.json();
if(typeof(callback) === 'function') callback(responseJson);
}catch(error) {
// An error occurred while connecting
console.log(error);
if(typeof(callbackErr) === 'function') callbackErr(error);
}
}
export { getData };
Metadata
Metadata
Assignees
Labels
Platform: AndroidAndroid applications.Android applications.Ran CommandsOne of our bots successfully processed a command.One of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.Type: QuestionIssues that are actually questions and not bug reports.Issues that are actually questions and not bug reports.🌐NetworkingRelated to a networking API.Related to a networking API.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]Android | I can not query on a local server (localhost) with fetch library, error "Network request failed"[/-][+][android] I can not query on a local server (localhost) with fetch library, error "Network request failed"[/+]react-native-bot commentedon May 15, 2019
We are automatically closing this issue because it does not appear to follow any of the provided issue templates.
👉 Click here if you want to report a reproducible bug or regression in React Native.