@@ -29,7 +29,7 @@ const mappings = {
2929
3030function onClick ( ) {
3131 let trelloApiKey = "afadffe77f745496f80ebb4bf460c615"
32- trektorStorage . get ( [ 'trello' , 'toggl' ] ) . then ( result => {
32+ trektor . storage . get ( [ 'trello' , 'toggl' ] ) . then ( result => {
3333 const trelloToken = result . trello
3434 const togglToken = result . toggl
3535
@@ -86,12 +86,12 @@ function onClick() {
8686
8787 url = new URL ( "https://api.track.toggl.com/api/v8/workspaces" )
8888 const togglAuth = btoa ( `${ togglToken } :api_token` )
89- trektorRuntime . sendMessage ( [ url . toString ( ) , {
89+ trektor . fetchJSON ( url . toString ( ) , {
9090 headers : {
9191 'Authorization' : `Basic ${ togglAuth } ` ,
9292 'Content-Type' : 'application/json'
9393 }
94- } ] ) . then ( response => {
94+ } ) . then ( response => {
9595 for ( var i in response ) {
9696 if ( response [ i ] [ "name" ] == "aboutsource" ) {
9797 var wid = response [ i ] [ "id" ]
@@ -103,12 +103,12 @@ function onClick() {
103103 }
104104
105105 url = new URL ( `https://api.track.toggl.com/api/v8/workspaces/${ wid } /projects` )
106- trektorRuntime . sendMessage ( [ url . toString ( ) , {
106+ trektor . fetchJSON ( url . toString ( ) , {
107107 headers : {
108108 'Authorization' : `Basic ${ togglAuth } ` ,
109109 'Content-Type' : 'application/json'
110110 }
111- } ] ) . then ( response => {
111+ } ) . then ( response => {
112112 for ( var i in response ) {
113113 if ( response [ i ] [ "name" ] . endsWith ( `(${ labelShort } )` ) ) {
114114 var pid = response [ i ] [ "id" ]
@@ -120,14 +120,14 @@ function onClick() {
120120 "pid" : pid
121121 }
122122 }
123- trektorRuntime . sendMessage ( [ url . toString ( ) , {
123+ trektor . fetchJSON ( url . toString ( ) , {
124124 method : 'POST' ,
125125 headers : {
126126 'Authorization' : `Basic ${ togglAuth } ` ,
127127 'Content-Type' : 'application/json'
128128 } ,
129129 body : JSON . stringify ( data )
130- } ] )
130+ } )
131131 }
132132 }
133133 } )
0 commit comments