M
M
Mothersprogrammer2020-08-21 16:14:51
Node.js
Mothersprogrammer, 2020-08-21 16:14:51

Why is vue not finding the file?

There is a method that sends an array to node, it is converted to a string and placed in json

postJson(url, data){
            return fetch(url, {
                method: 'POST',
                headers: {
                    "Content-Type": "application/json"
                },
                body: JSON.stringify(data)
            })
                .then(() => JSON.stringify(data))
                
        },

calling the method
this.postJson("todo.json", this.todos)
gives an error that the file does not exist (404)
although everything is OK here everything works
fetch('todo.json')
            .then(result => result.json())
            .then(data => {
                  this.todos = data;
            })

What needs to be corrected please?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2020-08-21
@Nc_Soft

app.post('dist/todo.json'
change to
app.post('/todo.json'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question