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

Missing request token for request

$
0
0

Get all contacts from phonebook and upload to server but got following error.

While append image in request body FormData

enter image description here

Tried code

pass file url contact thumbnailPath

const path = con.thumbnailPathbody.append('image', {     uri: path,     type: 'image/jpeg',     name: 'photo.jpg',     type: 'multipart/form-data'})

Tried code

pass file url contact thumbnailPath without "file://"

const path = con.thumbnailPath.replace('file://', '')body.append('image', {     uri: path,     type: 'image/jpeg',     name: 'photo.jpg',     type: 'multipart/form-data'})

Tried code

check file exist on path or not with using react-native-fs

if (con.thumbnailPath != '') {     let isExist = RNFS.exists(con.thumbnailPath)     if (isExist) {         const path = con.thumbnailPath.replace('file://', '')         console.log("Exist", path)         body.append('image', {             uri: path,             type: 'image/jpeg',             name: 'photo.jpg',             type: 'multipart/form-data'         })     }}

Request

fetch(url, {    method: 'POST',    headers: {'Authorization': token,'token': token    },    body: params }).then((res) => res.json()).then((json) => {    console.log("RESPONSE:- ", json)    if (json.response[0].status == 'false') {        let msg = json.response[0].response_msg        callback(new Error(msg), json.response[0])    }    else {        callback(null, json.response[0])    }}).catch((err) => {    console.log(err)    callback(err, null)})

Viewing all articles
Browse latest Browse all 16552

Trending Articles



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