'How to ressolve TypeError: Network Request Failed for react project running at android device

While running my react native app on android device using expo the api response are not coming which is done using fetch and POST method and getting this error:

[Unhandled promise rejection: TypeError: Network request failed]
at node_modules\whatwg-fetch\dist\fetch.umd.js:535:17 in setTimeout$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:383:16 in callTimers
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
at [native code]:null in callFunctionReturnFlushedQueue

This is my promise:

async fetchesponse() {
    var details = {
        'APP_STUDY_ID': this.state.studyId,
        'APP_PATIENT_DIARY_ID': this.state.diaryId,
        'P_TOKEN': this.state.pToken
    };
    var formBody = [];
    for (var property in details) {
        formBody.push(encodeURIComponent(details[key]) + "=" + encodeURIComponent(details[property]));
    }
    formBody = formBody.join("&");
    let resp = await fetch(this.state.apiUrl, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        body: formBody
    })
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source