gpt4 book ai didi

php - 类型错误 : "Cannot convert string to ByteString because the character at index 519 has value 8230 which is greater than 255."

转载 作者:行者123 更新时间:2023-12-04 02:53:52 27 4
gpt4 key购买 nike

我目前在 laravel 和 react js 工作。我已经在 laravel 中创建了 api 端点,用于使用 laravel 护照登录注册。现在,当提供 api_token 时,我已经制定了以下路线来获取用户详细信息。

路线

Route::group(['middleware' => 'auth:api'], function(){
Route::post('details', 'API\UserController@details');
});

这是 Controller ,

Controller
/** 
* details api
*
* @return \Illuminate\Http\Response
*/
public function details()
{
$user = Auth::user();
return response()->json(['success' => $user], $this->successStatus);
}

react
import React,{Component} from 'react';
import axios from 'axios';

export default class Home extends Component{
constructor(props){
super(props);
this.state = {
name: '',
email: '',
}
}
componentDidMount() {
axios.get(
'127.0.0.1:8000/api/details/',
{
headers: {
'Content-Type':'application/x-www-form-urlencoded',
'Authorization':'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImNmMTkxMjQ0ZWVhZmJlZjNmMDljM2ExMDc0MzgwZjE2ZGY2MGY3YTAwOGI0ZmQyZjY4OTI2NWJiZWJlNGIzNTU0ZDNhZGM1ZDNhOTk2ODgzIn0.eyJhdWQiOiIzIiwianRpIjoiY2YxOTEyNDRlZWFmYmVmM2YwOWMzYTEwNzQzODBmMTZkZjYwZjdhMDA4YjRmZDJmNjg5MjY1YmJlYmU0YjM1NTRkM2FkYzVkM2E5OTY4ODMiLCJpYXQiOjE1NDU1ODQ4ODYsIm5iZiI6MTU0NTU4NDg4NiwiZXhwIjoxNTc3MTIwODg2LCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.rRgHTChM8n-3r6syYaH9t0KKQLYLki9_jAsg6UUtX5Y3KUznr8IuAQnPKpuy-6jirEtjB6lG5GA6z7vHonp0YH-dWR3VxRfw_69vf6DfV0Z1yVzqitz7h-zsbC4j…BT_roRITEVusZWogUcpgMrvZs-jbVpfb6DpfNE0RA9ID2t_LSK9wlIc7_LeZFgqwPhBr90aUjpWQNnAfPg8l_DiWWAZLWoSRlYswQ9pQkIwyI-QYfTfIXxAKDdnOTLn7u4cLx1a_lj0IrIudlLPAPI3gqeJWzYYD8e3y7TuQtUv3zvb7rzW-AT6dV2RQO-bzd4OZDraRzrRbhc1qmYy1v0o0FkRxKgIagx69iIjwEyH7wwG08tq9OSptRtviGKZk1cu5T9qywDc4fA61_3lEPPACh_hUgdUc7qOnaKk3mU8nfnonSA0NQzfV_nK9PvGG_NzUQVk4Gei3YEqsUBl-JgofIEO310OBL9cgfa7cFjPMaw90o6XcP9c3abZZFHWGhVJPSrzyLidr_rC2RVhX5M7UvNDxS5Rw-bOWpQiYhd69_-Jk3B92gFWbLk4IBRqkaxGhEmV7netaTkFDF_e0f-R7HjUhicDJe6HQKCBFqzsAwSyax7NoFquWxZeJ4EA',
'Accept':'application/json'
}
}
).then(response => {
this.setState({
name: response.success.name,
email: response.success.email
});
}).catch(error=>{
console.log(error);

});
}

render(){
return(
<div>
<h4>Name: {this.state.name}</h4>
<h4>Email: {this.state.email}</h4>
</div>
);
}
}

当我使用 api_token 发送请求时,出现以下错误。

TypeError: "Cannot convert string to ByteString because the character at index 519 has value 8230 which is greater than 255."

setRequestHeader http://localhost:3000/static/js/bundle.js:876:11

forEach http://localhost:3000/static/js/bundle.js:2339:9

dispatchXhrRequest http://localhost:3000/static/js/bundle.js:870:7

xhrAdapter http://localhost:3000/static/js/bundle.js:762:10

dispatchRequest http://localhost:3000/static/js/bundle.js:1375:10



我做错了什么任何建议/帮助表示赞赏。

最佳答案

我遇到了同样的错误,发现是由于头字符串包含Unicode字符。在上面的例子中,授权包含“…”。

关于php - 类型错误 : "Cannot convert string to ByteString because the character at index 519 has value 8230 which is greater than 255.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53905825/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com