Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to get gen2 function working? #1038

Answered by ryanmio
thecannabisapp asked this question in Q&A
Discussion options

I've followed the docs, but I get a 500 error when I call the function.

Screenshot 2023年02月06日 at 23 10 18

Below is my code from the client.

 try {
 const response = await httpsCallableFromURL<unknown, IToken>(
 functions,
 "https://getstreamtokenv2-nnvm3z4kea-ez.a.run.app/getstreamtokenv2"
 )();
 return response.data;
 } catch (error) {
 throw new Error("token error");
 }
You must be logged in to vote

Your 500 error indicates a server-side issue. The client code is simply the caller and can't fix a 500 error coming from the server. Make sure the function at https://getstreamtokenv2-nnvm3z4kea-ez.a.run.app/getstreamtokenv2 is working as expected.

Debugging Steps:

  1. Check Server Logs: Look at the server-side logs to identify the cause of the 500 error.

  2. Local Testing: If possible, test the function locally before deploying.

  3. Dependencies: Ensure all dependencies are correctly installed on the server.

  4. Request and Response: Ensure that the request and response formats are correct according to your function's expectations.

Here's an example of how you might log errors in your cloud fu...

Replies: 1 comment

Comment options

Your 500 error indicates a server-side issue. The client code is simply the caller and can't fix a 500 error coming from the server. Make sure the function at https://getstreamtokenv2-nnvm3z4kea-ez.a.run.app/getstreamtokenv2 is working as expected.

Debugging Steps:

  1. Check Server Logs: Look at the server-side logs to identify the cause of the 500 error.

  2. Local Testing: If possible, test the function locally before deploying.

  3. Dependencies: Ensure all dependencies are correctly installed on the server.

  4. Request and Response: Ensure that the request and response formats are correct according to your function's expectations.

Here's an example of how you might log errors in your cloud function:

exports.yourFunction = functions.https.onCall((data, context) => {
 try {
 // Your code here
 } catch (error) {
 console.error(error);
 throw new functions.https.HttpsError('internal', 'An internal error occurred');
 }
});

This should give you a clearer picture of what might be going wrong on the server-side.

You must be logged in to vote
0 replies
Answer selected by thecannabisapp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /