M
M
Mothersprogrammer2020-08-23 18:58:44
JavaScript
Mothersprogrammer, 2020-08-23 18:58:44

How to send array to node from js?

I make a POST request, and there is a json line in it, which should go to the node and already be written to the json document there,
it looks like this:

postJson(data){
            return fetch('todo.json', {
                method: 'POST',
                body: JSON.stringify(data),
                headers: {
                    'Content-Type': 'application/json'
                }
            })
              .then(response => {response.json()})
              .then(function(response) {
                  console.info('fetch()', response);
              });
                
        },


this.postJson(this.todos)
            .then(()=>{
              console.log(this.todos)
            })

the problem is that I don't know how to access the passed data in node, and whether it's possible at all.
Please tell me what needs to be done?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question