how to call Authorization bearer id in react native
this is my bakcend api
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.at.com/staging-achhamall.com/index.php?route=webservices/api&method=appAddAddress",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array('firstname' => '','lastname' => '','address_1' => '','city' => '','postcode' => '','state' => ''),
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer 72",
"Content-Type: multipart/form-data; boundary=--------------------------849034604955985124167342"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
и это мои собственные нативные коды
userSubmit = async() =>{
const {firstname} = this.state;
const {lastname} = this.state;
const{address_1}= this.state;
const {city} = this.state;
const {postcode} = this.state;
const {state} = this.state;
if(firstname=="" || lastname=="" || address_1=="" || city=="" || postcode=="" || state==""){
alert("Please fill out all fields");
}
// else if (password!=cpassword) {
// alert("Passwords do not match.");
// }
else{
fetch(URI, {
method: 'post',
header:{
'Accept': 'application/json',
'Authorization': 'Bearer 72',
},
body:JSON.stringify({
firstname:firstname,
lastname: lastname,
address_1 :address_1,
city :city,
postcode :postcode,
state :state,
})
})
.then((response) => response.json())
.then((responseJson) =>{
if(responseJson.response.status === 'sucess'){
Alert.alert(
'Success',
[
{text:'ok'}//onPress: () => this.props.navigation.navigate('Home')
]
);
console.log('uploaded');
// this.props.navigation.navigate('Home')
}else{
alert(responseJson.response.status);
}
})
.catch((error)=>{
console.log(error);
});
}
}
как использовать токен-носитель при вызове каждый раз, когда он выдает ошибку API, что не так с токеном-носителем, как мне писать и использовать ?
coz при использовании вот так: «Авторизация»: «Bearer 72» выдает ошибку токена ошибки <</p>
, где я получаю сообщение, дайте мне знать об этом?