A
A
Aleksandrov2017-07-26 15:33:40
JavaScript
Aleksandrov, 2017-07-26 15:33:40

Error sending request with fetch?

decided to slowly cut out jquery, started with ajax requests.

It was:

function uAjax(url, data, requestType){
  return	$.ajax({
    'type':requestType,
    'url':url,
    'dataType': 'json',
    'data':data
  })
}
uAjax("/info", {}, "GET")


Everything works, the request leaves, the data comes. Rewrote (according to https://github.com/github/fetch ):
import 'whatwg-fetch'
function uFetch(url, data, requestType){

  return fetch(url, {
    method: requestType,
    body: data
  });
}

uFetch("/info", {}, "GET").then((response) => {console.log(response.json());response.json()})


The request is not sent + I get a bunch of errors: 83o0qIXpQF69pRzdFtsjsw.png

What did I code wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
0
0xD34F, 2019-02-20
@s24344

const arrM = {
  list: arr.list.map(n => ({
    id: n.id,
    pos: {
      dv: n.pos.dV.match(/[\d\-]+/)[0],
    },
  })),
};

A
Aleksandrov, 2017-07-28
@alexandr2006

I say - the request is not sent (I don’t see it in the console), so first and third
i.prntscr.com/1olGmL8DRgW75m4dOeRyXQ.png
are not relevant after response.text():
i.prntscr.com/SMu52MA3TlK1ZXKmeZpd4w.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question