0

I´m trying to use Data Storage functionality of Freshdesk and it returns an error. I´m following this example.

My code to store the data is:

var ticket = domHelper.ticket.getTicketInfo().helpdesk_ticket;
var dataTicket = {
   'ticketId': ticket.display_id,
   'osNumber': idOS
};
var dbKey = "ticket:" + ticket.display_id;
this.$db.set(dbKey, dataTicket).done(function(data) {
     if(data.Created) {
          console.log("Dados de OS salvos com sucesso.");
     }
}).fail(function(errorData) {
     alert("Falha ao salvar dados de OS.");
});

This code works fine. To retrieve that data, I'm using the code below:

var ticket = domHelper.ticket.getTicketInfo().helpdesk_ticket;
var dbKey = "ticket:" + ticket.display_id;
this.$db.get(ticket.display_id).done(function(data) {
     self.loadData(data);
}).fail(function(errorData) {
     console.log("Falha ao recuperar dados de OS.");
});

The key to retrieve the data is the same that I use to store that data, but it always enter in fail function. It tells me that there isn't data (return 404 error of the API).

Dhaval Jardosh
  • 7,151
  • 5
  • 27
  • 69

1 Answers1

0

I´ve noticed that my key was different when I've tried to retrieve the data. I've fixed the problem using it:

var dbKey = "ticket:" + ticket.display_id;
this.$db.get(dbKey).done(function(data) {
     self.loadData(data);
});