'Using axios.post, response.data return html instead of data [Nodejs, React]

What I want is, when I click SUBMIT button, it should post some data using axios.post

const sb = async () => {
    axios.post('/tagSearch',{
      qual: qualQuery,
      sem: semQuery,
      etc: etcQuery,
      interest: iArr
    })
    .then(res => {
      console.log(res);
    }).catch(error => {
      console.log(error);
      throw new Error(error);
    });
  }


<Button
            onClick={sb}
          >
            SUBMIT
          </Button>

but console.log(res.data) result is

{data: '<!DOCTYPE html><html><head><style data-next-hide-f…r":true,"scriptLoader":[]}\x3C/script></body></html>', status: 200, statusText: 'OK', headers: {…}, config: {…}, …}
config: {transitional: {…}, transformRequest: Array(1), transformResponse: Array(1), timeout: 0, adapter: ƒ, …}
data: "<!DOCTYPE html><html><head><style data-next-hide-
headers: {access-control-allow-methods: 'OPTIONS, GET', access-control-allow-origin: 'http://localhost:3006', cache-control: 'no-store, must-revalidate', connection: 'keep-alive', content-encoding: 'gzip', …}
request: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}
status: 200
statusText: "OK"
[[Prototype]]: Object

and what I want is in this form

{"qual":[-1,-1,-1],"sem":[1,1,-1,-1],"etc":[1,1,-1,-1],"interest":[]}

And I tried to get that data in routes/tagSearch.js like

router.post('/tagSearch', function (req, res, next) {   
    const text = req.body;
    console.log('text:'+ text);
    res.send('About post');
})

IDK what's wrong.........



Solution 1:[1]

your proxy setting is not configured clearly.

use this, and provide your full backend url.

const sb = async () => {
    axios.post('http:localhost:3000/tagSearch',{
      data
    })
  }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wai Ha Lee