Back

Cloud function server response

  • 0
  • Functions
dammy
11 Jul, 2023, 01:22

Question 1: I am trying to get values of various keys from a decoded map that was encoded to string. when I tried:

TypeScript

final decoded = json.decode(response.response);
myMap = decoded;
if (kDebugMode) {
          print(decoded["S"][0]);
}

I kept getting the value of S but an index zero, even as 0 is also a key of another map on server

............

Question 2 Am unable to get more than one responses from the cloud function, only the last one is gotten as response, despite others are directly above it. I tried this:

TypeScript

   res.json({
          'MTN_CG_Values': mtnCGValues.toString(),
        });

   res.json({
          'MTN_CG_Model': mtnCGModel.toString(),
        });
TL;DR
The user is seeking help with two questions. Question 1: The user is trying to get values from a decoded map that was encoded to string. They are specifically trying to get the value of `decoded["S"][0]`. However, they are only getting the value of `S` at index 0, even though 0 is also a key of another map on the server. Solution: There is no provided solution in the support thread. Question 2: The user is unable to retrieve more than one response from a cloud function. They are only getting the last response as a result, even though there are multiple responses
Drake
11 Jul, 2023, 02:01

what is mtnCGValues and mtnCGModel?

dammy
11 Jul, 2023, 15:34

They are map @Steven

Though question 1 is resolved, remaining that of question 2

I discovered, in question 1 the map was converted to string via

TypeScript
.toString
dammy
11 Jul, 2023, 15:39

Thanks for coming through

What's left is the second question

Drake
11 Jul, 2023, 15:56

Would you pleas share what response.response is or exactly what mtnCGValues and mtnCGModel values are?

dammy
11 Jul, 2023, 16:05

Okay

dammy
11 Jul, 2023, 16:06
TypeScript
Map mtnCGModel = {
  // the pattern is |quantity | network | network ID | amount
  "0": ["MTN CG", 290, 170, "500MB", "30 DAYS", "1"],
  "1": ["MTN CG", 291, 280, "1GB", "30 DAYS", "1"],
  "2": ["MTN CG", 292, 550, "2GB", "30 DAYS", "1"],
  "3": ["MTN CG", 293, 820, "3GB", "30 DAYS", "1"],
  "4": ["MTN CG", 294, 1350, "5GB", "30 DAYS", "1"],
  // "5": ["MTN", 294, 2500, "10GB", "30 DAYS"],
};
List mtnCGValues = [
  "MTN CG 500MB",
  "MTN CG 1GB",
  "MTN CG 2GB",
  "MTN CG 3gb",
  "MTN CG 5GB",
];
Drake
11 Jul, 2023, 16:18

so why are you doing decoded["S"]? It doesn't look like there is any "S" key

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more