React-Native:发送日志时出现问题-console.error [英] React-native: Problem sending log - console.error

查看:73
本文介绍了React-Native:发送日志时出现问题-console.error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Expo React本机,我正在尝试使用axios将POST请求发送到我的快递服务器

I'm working with Expo React native, I'm trying to send POST request to my express server using axios

App.js-在我的React中

Axios({
   url:'http://172.20.1.19:3001/api/tracking/locator',
   method:'POST',
   data:{
      test:'wew'
   },
   config:'JSON',
   headers:{
     "Access-Control-Allow-Origin": "*"
   }
})
.then(res=>{
   console.log(res)
})
.catch(err=>{
   console.log(err)
})

在节点状态下为200,但是当console.log响应时,它将引发错误

In node status its 200, but when console.log the response it throws an error

console.error.向您发送日志消息时出现问题开发环境",

console.error. "There was a problem sending log message to your development environment",

Tracking.js-Express

var express = require('express');
var cors = require('cors');
var router = express.Router()
const app = express();


const db = require('../models');

app.use(cors({origin:'http://172.20.1.19:19001'}));


router.get('/', function(req, res, next){ 
    res.json({
        data: {
            test :'wew'
        }
    })
})


router.post('/locator', function(req,res,next){
    res.json({
        data:{
            status:'pano mo nasabe'
        }
    })
})


module.exports = router

推荐答案

尝试使用:

(这对我有帮助)

console.log(JSON.stringify(response.data))  

console.log(response.data)

console.log(JSON.stringify(response))  

这篇关于React-Native:发送日志时出现问题-console.error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆