在React Native中将授权标头与Fetch一起使用
我试图fetch在React Native中使用以从Product Hunt API获取信息。我已经获得了正确的访问令牌并将其保存到State,但是似乎无法在GET请求的Authorization标头中传递它。 这是我到目前为止的内容: var Products = React.createClass({ getInitialState: function() { return { clientToken: false, loaded: false } }, componentWillMount: function () { fetch(api.token.link, api.token.object) .then((response) => response.json()) .then((responseData) => { console.log(responseData); this.setState({ clientToken: responseData.access_token, }); }) .then(() => { this.getPosts(); }) .done(); }, getPosts: function() { var obj …