type
status
date
slug
summary
tags
category
icon
password
內容
最近在使用React Native開發跨平台APP使用Fetch時,遇到Server API會記錄的Cookie,導致如果直接使用Fetch會產生非預期的結果。
例如有一個註冊API如下:
預設會送出cookie導致Server API傳回已經註冊過的問題。
但是可以加上
credentials: 'omit'後,就可以不會送出Cookie了。結果改成:
沒想到React Native預設會像瀏覽器一樣的行為。
測試
參考在stackoverflow上的問題
react-native fetch() cookie persist
在2015年11月的React Native 0.16版本,Android及iOS的fetch都會設定
credential