Json Encode problems while using Google Firebase, is there any solutions?
Today i just started using Google Firebase, after finding out it could help my problem with quick data transfer between servers.
I am trying to use Google Firebase to get data quickly from server to server, but ran into this problem when i tried using the module script for this. Apparently trying to call one of the functions to give data always led to an error.
I would very much appreciate it if someone with experience with Firebase could give their advice on how to solve this problem. And underneath this is both the script and module script i used.
Here is the Script that uses the module script:
1 | local Data = require(script.Firebase) |
7 | Data:Patch( "users/4402987" , { level = 9000 , name = "astrallife" } ) |
And here is the Module script itself: https://www.roblox.com/catalog/297221345/Rukiryos-Firebase-Module
I will still show the rest of the script here, for your convenience.
094 | module.Init = function (u) |
096 | module.http = game:GetService( "HttpService" ) |
099 | module.Authenticate = function (key) |
103 | module.Post = function (path, data, header) |
104 | if header = = nil then header = "" end |
105 | local jData = module.http:JSONEncode(data) |
106 | local finalPath = module.AuthKey(module.url..path.. ".json" ..header) |
108 | return module.http:PostAsync(finalPath, jData) |
111 | module.Get = function (path) |
112 | local sendData = module.AuthKey(module.url..path.. ".json" ) |
114 | local gottenData = module.http:GetAsync(sendData) |
116 | if gottenData ~ = "null" then |
117 | return module.http:JSONDecode(gottenData) |
122 | module.Put = function (path, data) |
123 | return module.Post(path, data, "?x-http-method-override=PUT" ) |
126 | module.Patch = function (path, data) |
127 | return module.Post(path, data, "?x-http-method-override=PATCH" ) |
130 | module.Delete = function (path) |
131 | return module.http:PostAsync(module.AuthKey(module.url..path.. ".json?x-http-method-override=DELETE" ), module.http:JSONEncode( { } )) |
134 | module.AuthKey = function (str) |
135 | if module.auth = = "" then return str end |
136 | if str.find(str, "?" ) ~ = nil then |
137 | return str.. "&auth=" ..module.auth |
139 | return str.. "?auth=" ..module.auth |