1
votes

Api import:

import axios from 'axios';
const Api = axios.create({ baseURL: 'exp://IP:19000' });
export default Api;

Component where I'm using it:

const handlePress = async () => {
    try {
      await TaskService.create({ title: title })
    } catch (error) {
      console.error(error)
    }
  }

I was getting a warning before, but after I used trycatch I started to get this error: Network Error

Stack trace: node_modules/axios/lib/core/createError.js:16:14 in createError node_modules/axios/lib/adapters/xhr.js:84:24 in handleError node_modules/event-target-shim/dist/event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent node_modules/react-native/Libraries/Network/XMLHttpRequest.js:600:10 in setReadyState node_modules/react-native/Libraries/Network/XMLHttpRequest.js:395:6 in __didCompleteResponse node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js:189:10 in emit node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:416:4 in __callFunction node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:109:6 in __guard$argument_0 node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10 in __guard node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:108:4 in callFunctionReturnFlushedQueue [native code]:null in callFunctionReturnFlushedQueue

1

1 Answers

0
votes

try to use .then() .catch() promise