Closed chriscalo closed 5 years ago
See https://github.com/chriscalo/goldpage-vue-express-starter/pull/2.
The need to use bind()
when using Wildcard with SSR is explained here: https://github.com/reframejs/wildcard-api/blob/master/docs/ssr-auth.md#readme
As usual, let me know if something's not clear.
I'm going to answer to the rest later.
it blows up with the following error
An edge case led to this unfriendly error to be thrown. It's now fixed in the newly published version 0.5.4
; the proper original error message that explains what's going on is now shown instead. I'm sorry you didn't see the proper error message — I do care about error messages that contain an explanation.
Thanks for the fix! š I'll give the a try today.
I'm sorry you didn't see the proper error message ā I do care about error messages that contain an explanation.
No worries, I get that these libs are still very early in their maturity. I deeply appreciate your responsiveness to these issues when they come up.
It appears that Wildcard API is already trying to set this
when calling the endpoint method by using endpoint.apply()
. Any idea why this isn't working? (Is it the use of Proxy
? Or am I not reading this right?)
async function runEndpoint({endpointName, endpointArgs, requestProps, isDirectCall}) {
// ...
const endpoint = endpointsObject[endpointName];
// ...
const requestProps_proxy = create_requestProps_proxy({requestProps, endpointName, isDirectCall});
let endpointResult;
let endpointError;
try {
endpointResult = await endpoint.apply(
requestProps_proxy,
endpointArgs,
);
} catch(err) {
endpointError = err;
}
// ...
}
Perhaps the more important question: is there somewhere I can put this binding logic once so I don't have to do it on every endpoint call?
You can read about bind()
here. It explains why bind()
is necessary when using the Wildcard client in Node.js.
Perhaps the more important question: is there somewhere I can put this binding logic once so I don't have to do it on every endpoint call?
I'm afraid not; this is inherent to SSR. You'll always have to manually provide the HTTP request information while doing SSR, no matter whether you use RPC, REST, or GraphQL.
I now see why the request info must be manually provided. š Thanks for the explanation.
You'll always have to manually provide the HTTP request information while doing SSR
That said, one thing I want to do is to have Goldpage automatically provide requestProps
to Wildcard. Although there will be some edge cases where the user will still need to use bind()
.
The getting started section of the Wildcard API docs state that
this
will be equal to therequestProps
object passed togetApiResponse()
.I tried
console.log()
ingthis
from an endpoint function:Unfortunately, it blows up with the following error:
See the bug-when-logging-this-in-endpoint-function branch to reproduce this error.