Re: [w3c/payment-request] editorial: add example of .toJSON()+fetch POST (#583)

marcoscaceres commented on this pull request.



> +          "fetch">Fetch API</a>:
+        </p>
+        <pre class="example">
+          async function doPaymentRequest() {
+            const payRequest = new PaymentRequest(methodData, details, options);
+            const payResponse = await payRequest.show();
+            let result = "unknown";
+            try {
+              const httpResponse = await fetch("/process-payment", {
+                method: "POST",
+                headers: new Headers({ "Content-Type": "application/json" }),
+                body: payResponse.toJSON(),
+              });
+              result = httpResponse.ok ? "success" : "fail";
+            } catch (err) {
+              console.error(err);

yeah, me too :( Ok, will just add a comment about "unknown" that it's an option that people can use if they need it... however, we should try to come up with something real or we should mark it "at risk".

Chrome currently does nothing with "unknown" (behaves the same as "success", in that no error is shown to the user). I don't know if we (Firefox) will do anything with "unknown" at this point.  

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/payment-request/pull/583#discussion_r133353277

Received on Wednesday, 16 August 2017 03:40:06 UTC