- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前在 laravel 和 react js 工作。我已经在 laravel 中创建了 api 端点,用于使用 laravel 护照登录注册。现在,当提供 api_token 时,我已经制定了以下路线来获取用户详细信息。
路线
Route::group(['middleware' => 'auth:api'], function(){
Route::post('details', 'API\UserController@details');
});
/**
* details api
*
* @return \Illuminate\Http\Response
*/
public function details()
{
$user = Auth::user();
return response()->json(['success' => $user], $this->successStatus);
}
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>
);
}
}
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/
运行以下代码: import Crypto.BCrypt import Data.ByteString.Lazy.Char8 main = do maybe_pwhash <- hashPassw
此代码不进行类型检查: import Network.HTTP.Conduit import qualified Data.ByteString.Char8 as BS main :: IO () m
我一直在尝试解决problem 1330来自 Haskell 的 acm.timus.ru。基本上,它归结为: 1) 从标准输入中读取一个长度为 N (N < 10^4) 和 M 对整数 (M < 1
我正在学习 Haskell,并决定尝试编写一些小型测试程序来习惯 Haskell 代码和使用模块。目前我正在尝试使用第一个参数来使用 Cypto.PasswordStore 创建密码哈希。为了测试我的
尝试编写一个返回我计算机的外部 IP 地址的模块。 使用 Network.Wreq get函数,然后应用一个镜头得到responseBody ,我最终得到的类型是 Data.ByteString.La
这是我在 Haskell 中尝试做的事情: 以 ByteString 格式获取消息(惰性或严格并不重要) 使用 RSA 公钥加密消息 对加密消息进行 Base64 编码 RSA library我正在使
我读到 Char8 仅支持 ASCII 字符,如果您使用其他 Unicode 字符,使用起来会很危险 {-# LANGUAGE OverloadedStrings #-} --import quali
我实现了读取 ByteString 并将其转换为十六进制格式的函数。 例如。给定“AA10”,它将其转换为 [170, 16] import qualified Data.ByteString.Laz
我对 real world haskell 中的代码有点困惑 import qualified Data.ByteString.Lazy.Char8 as L8 import qualified Da
我知道我已经有了 Haskell Data.ByteString.Lazy 函数来拆分单个字符的 CSV,例如: split :: Word8 -> ByteString -> [ByteString
需要从已离开的开发人员那里修补 Haskell 项目,但我是一个完整的 Haskell 菜鸟。 尝试编写一个函数来返回与某个模式匹配的所有 Redis 键的数量。交互地,它看起来像这样: *MyPro
我正在尝试在我的 Haskell 代码中启动并运行一个简单的 Json 解析器,我遇到了 Data.Aeson,这似乎是解决我的问题的可行解决方案 我关注了example code on the pa
我正在将包从使用 GHC.IO.Handle 进行网络转换为 Network.Connection.Connection。痛点之一是 Data.ByteString.Lazy.ByteString 更
我正在尝试为 django 应用程序设置数据库。 因此,当我尝试创建数据库时,除了一件事之外,一切正常。最后,出现以下消息: You just installed Django's auth syst
在 Python 中使用 SQLite3,我正在尝试存储 UTF-8 HTML 代码片段的压缩版本。 代码如下: ... c = connection.cursor() c.execute('crea
我正在编写一个脚本,它递归地扫描一个目录并将它们存储在一个字典中,该字典是一个列表的集合。该列表中包含具有文件名和文件大小的列表。此文件名可能包含 UTF-8 字符,如下所示。 ['test.rus
问候, 我试图理解为什么我看到整个文件使用以下程序加载到内存中,但是如果您注释掉“(***)”下面的行,那么程序会在恒定(大约 1.5M)空间中运行。 编辑:该文件大约 660MB,第 26 列中的字
对于字符串有 ++ , 它有类型 > :t (++) (++) :: [a] -> [a] -> [a] 显然它不适用于 ByteString因为它不是一个列表。我看到 append 功能,但它有一个
最近在我的项目上运行基准测试后,我发现直接构建严格的字节串可以比涉及构建器的构建快一个数量级。 例如,使用构建器的编码器实现: encoder :: Int64 -> Data.ByteString.
我希望压缩我的应用程序的网络流量。 根据(最新?)"Haskell Popularity Rankings" , zlib似乎是一个非常受欢迎的解决方案。 zlib的接口(interface)使用By
我是一名优秀的程序员,十分优秀!