How to attach headers on a payload during api post request in framework7

58 Views Asked by At

I am new in framework7, I am trying to send request to the api using fetch method, the api need authorization, The way I did it seems to be not recognised by Framework7, below is what I did:

               app.request
              .post("http://127.0.0.1:8000/api/sellEletricity/"+ phone_number, {
                meterNumber: meterNumber,
                transactionValue:transactionValue,
                headers: {
                  "Content-Type": "application/json",
                  "Authorization": token
              },
            }).then(function (res) {
              app.preloader.hide();
              var data = JSON.parse(res.data);
              console.log(data);

The error I getting says "user is not authorised" meaning the api didnt get the token provided inside the headers. any info regarding above mentioned error.

0

There are 0 best solutions below