小编Cit*_*rix的帖子

结合Nodejs + React Native + Axios + CORS

我正在尝试使用Axios从前端(react-native)向我的API(Node.JS)发出请求.但我对我得到的错误感到困惑.这是错误的打印堆栈跟踪:

Network Error
- node_modules\axios\lib\core\createError.js:16:24 in createError
- node_modules\axios\lib\adapters\xhr.js:87:25 in handleError
- node_modules\event-target-shim\lib\event-target.js:172:43 in dispatchEvent
- node_modules\react-native\Libraries\Network\XMLHttpRequest.js:554:29 in setReadyState
- node_modules\react-native\Libraries\Network\XMLHttpRequest.js:387:25 in __didCompleteResponse
- node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:182:12 in emit
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:302:47 in __callFunction
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:116:26 in <unknown>
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:265:6 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:115:17 in callFunctionReturnFlushedQueue
Run Code Online (Sandbox Code Playgroud)

因此,我不确定是否需要使用Axios配置某些内容以允许与后端进行通信,或者我是否必须配置后端以允许使用前端的请求.这是我对CORS后端服务器的配置:

// server.js
var app = require('./app');

var routes = require('./routes');
var port = process.env.PORT || 3001;
var cors = require('cors');

app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  next();
});

var server = …
Run Code Online (Sandbox Code Playgroud)

node.js cors react-native axios

3
推荐指数
1
解决办法
2849
查看次数

Nativebase:更改缩略图默认大小

我无法从NativeBase更改缩略图的默认大小。我可以显示默认的圆,即小和大的圆,但是我想显示比默认尺寸大的圆。这是我的缩略图代码:

<Thumbnail size={200} style={{margin: 30}} source={require('../../../public/images/profile/yellow.jpg')} />
Run Code Online (Sandbox Code Playgroud)

道具大小无效,缩略图仍然很小。

我的NativeBase版本:2.3.5

size thumbnails native-base react-props

2
推荐指数
1
解决办法
3843
查看次数