[Vuejs]-How to create a login system using mongodb through the REST API?

0๐Ÿ‘

โœ…

You need to make your login function async.

methods: {
    login: async function (e) {

0๐Ÿ‘

You need to make your login function async โ€“

methods: {
login: async function() { ...

0๐Ÿ‘

Hi Madhu nice seeing you here again. Ok so Jakub is correct that you should put the async behind the function. Also, Remember that .then and await do the same things , so you either use one or the other. In this case, what you want to do is this

const response = await fetch(
      "http://localhost:3000/authentication/login", 
      {
        method: "POST",
        headers: {
          "Content-type": "application/json"
        },

        body: JSON.stringify(body)

      }

    );

Leave a comment