Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

500 error while doing a put/post/patch request in react native ios

$
0
0

I am attempting to create a put request to my react native (0.60.4) ios project and every time I do so I receive a 500 error when making my request. I am getting the same error while doing a post or patch method as well. I also receive a 500 error while attempting to make the request with postman.

My sql update works fine as I have ran the script against the database and received the expected value, which is simply updating a boolean value.

Here is my update method in redux

export const setChecklistItemToComplete = checklistItemId => {
  var checklistItemInstance = axios({
    method: 'put',
    url: `http://localhost:8080/xxxxxxxx/${checklistItemId}`,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      'Access-Control-Allow-Origin': '*'
    }
  })
  console.log('checklistItemInstance: ', checklistItemInstance)
  return {
    type: MARK_CHECKLIST_ITEM_COMPLETE,
    payload: checklistItemInstance.data
  }
}

Here is my controller

  try {
    const db = req.app.get('db')
    const { MarkChecklistItemComplete } = db.checklistItem.put
    const { params = {} } = req
    const { checklistItemId } = params

    if (joi.string().guid(checklistItemId)) {
      throw new Error('The id is not in the correct format')
    }

    console.log('checklistItemId: ', checklistItemId) <---GETS TO HERE
    var checklistItemInstance = await MarkChecklistItemComplete({
      checklistItemId
    })

    res.status(200)
    res.json(checklistItemInstance)
  } catch (error) {
    res.status(500)
    res.json(error)
  }
}

I'm assuming this has nothing to do with this code here but more so the configuration of the app itself. But it can't hurt to post it. If there is anything else you would like to see I will gladly share that.


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>