Я делаю axios запрос но получаю при этом не ответ а html разметку, не пойму как исправить данную ошибку?
Вот моя реализация
Home.js
import React, {Component} from 'react';
import { connect } from 'react-redux';
import axios from 'axios';
class Home extends Component{
constructor(props){
super(props);
}
componentWillMount(){
axios.get('/api/test-thema').then(response => console.log(response.data));
}
...
}
const mapStateToProps = state => ({
user: state.login.user
});
export default connect(mapStateToProps)(Home);
В router.js. Делаю на koa
router.get('/api/test-thema', async ctx => {
ctx.body = await Test.allThemes(1);
})
И в моделе Test
let Test = {
allThemes: function(id){
return requestTest('SELECT name FROM thema id_possition = ?', id);
},
...
};
function requestTest(sql, req) {
return new Promise((resolve, reject) => {
db.query(
sql,
[req],
(err, rows) => {
if(err) reject(err);
resolve(rows);
});
});
}
module.exports = Test;
Только вывыодит ответ в консоле браузера вот такой
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><meta http-equiv="x-ua-compatible" content="ie=edge"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.4/css/bootstrap.min.css" integrity="2hfp1SzUoho7/TsGGGDaFdsuuDL0LX2hnUp6VkX3CUQ2K4K+xjboZdsXyp4oUHZj" crossorigin="anonymous"><link rel="stylesheet" type="text/css" href="/css/index.css"><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js" integrity="sha384-THPy051/pYDQGanwU6poAc/hOdQxjnOEXzbT+OuUAFqNqFjL+4IGLBgCJC3ZOShY" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.2.0/js/tether.min.js" integrity="sha384-Plbmg8JY28KFelvJVai01l8WyZzrYWG825m+cZ0eDDS1f7d/js6ikvy1+X+guPIB" crossorigin="anonymous"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.4/js/bootstrap.min.js" integrity="VjEeINv9OSwtWFLAtmc4JCtEJXXBub00gtSnszmspDLCtC0I4z4nqz7rEFbIZLLU" crossorigin="anonymous"></script></head><body><div id="content"></div><script src="/client/bundle.js"></script></body></html>
Но в консоле node ничего не выводит почему-то не знаю почему