I'm trying to send an email when a user signs up. ...
# prisma-whats-new
a
I'm trying to send an email when a user signs up. I tried the mailgun example from https://www.graph.cool/docs/reference/functions/server-side-subscriptions-ahlohd8ohn/ But when the function triggers i get this: "Call to https://wt-graphcool.it.auth0.com/api/run/cj6moe68l0dhw0178sb2qk2xc/cj7f8b37d001c01qpwiib0hys failed with status 400". I don't use Auth0 at all, anybody have a clue why this happens?
a
You implemented it as a SSS? Does a test run work? Are you seeing anything else in the invocation logs, usually the reason for the 400 follows right after?
a
Yep, the full error log: {"error":"Call to https://wt-graphcool.it.auth0.com/api/run/cj6moe68l0dhw0178sb2qk2xc/cj7f8b37d001c01qpwiib0hys failed with status 400, response body {\n \"code\": 400,\n \"error\": \"Error when JSON serializing the result of the JavaScript code.\",\n \"details\": \"TypeError: Converting circular structure to JSON\",\n \"name\": \"TypeError\",\n \"message\": \"Converting circular structure to JSON\",\n \"stack\": \"TypeError: Converting circular structure to JSON\\n at Object.stringify (native)\\n at /data/sandbox/lib/sandbox.js82748\\n at /data/io/8c26235693364c19a885a11e92a009f4/webtask.js4633\\n at process._tickDomainCallback (node.js4819)\"\n} and headers [date: Sun, 10 Sep 2017 210618 GMT | Connection: keep-alive | content-type: application/json | x-auth0-stats: {\"worker_pid\":1,\"response\":{\"400\":1},\"time\":539,\"uptime\":509.99,\"memory\":{\"rss\":51757056,\"heapTotal\":31953920,\"heapUsed\":19937968,\"external\":440308}} | x-frame-options: DENY | transfer-encoding: chunked | x-auth0-proxy-stats: {\"proxy_host\":\"172.28.64.50\",\"proxy_pid\":37,\"container_id\":\"01356f3f-2207-46d5-b179-2b8f5667d887\",\"latency\":598,\"uptime\":1128318.306,\"memory\":{\"rss\":97816576,\"heapTotal\":63930112,\"heapUsed\":53273672,\"external\":20004876},\"req_id\":\"1505077577507.764406\"} | x-wt-response-source: sandbox]"}
a
That error is usually indicative of an error response from the API (in this case, Mailgun)
a
Ok, hmm, so why does it try to call auth0.com?
a
That's where the SSS function runs, it's the Auth0 Extend environment that Graphcool uses to run all your functions
a
Ahh, ok. Thanks for the help!
😎 1
a
Instead of returning fetch directly, you can use:
Copy code
fetch(...)
   .then(response => { ... })
   .catch(error => { ... }
to have more control over the process, and do some console.log() calls in there
a
Thanks, I'll do that! I probably need to take a closer look at the mailgun api first 🙂
I got it working now, thanks for the help. The example is wrong as Mailgun requires an username to be used with basic auth.
a
I see what you mean, the apiKey variable should be 'api:key'.
a
yep
a