Conversation
|
Note that the updateProfileImage endpoint does not yet exist, but will be merged soon by Leo here: https://github.com/kiva/kiva/pull/14077 I also added an optional appHost parameter to the useImageUpload function for local dev purposes because this will not work locally unless we hit dev... This should just default to the appropriate url for the environment when we are in dev / staging / prod envs though. |
| preFetch: true, | ||
| result({ data }) { | ||
| this.loading = false; | ||
| console.log('lenderProfileQuery result', data?.my?.lender ?? data); |
| const isViewingFromDifferentOrigin = typeof window !== 'undefined' && appOrigin | ||
| && window.location.origin !== appOrigin; | ||
| const uploadEndpoint = isViewingFromDifferentOrigin ? `${appOrigin}/img/upload` : '/img/upload'; | ||
| const response = await fetch(uploadEndpoint, { |
There was a problem hiding this comment.
Are we using REST endpoint instead of gql?
There was a problem hiding this comment.
Just curious, why was that needed?
There was a problem hiding this comment.
I was asked to port over this functionality and use cms-page-server as the precedent example.
The cms-page-server does the same thing: it uses a REST endpoint for the image upload.
In cms-page-server (composables/useImageUpload.ts):
It builds multipart form data and sends it with $fetch('/img/upload', { method: 'POST', body: formData }).
It does not use a GraphQL mutation for the file upload.
After a successful upload it gets back an image object (with id) and returns that id for use in a GraphQL mutation to attach the image to a profile.
The GraphQL multipart spec is not supported by our server or client as far as I know.
|
oops, I just saw that this was approved and merged prematurely before noticing there were also comments. I'll make the requested changes now in a separate commit sorry |
No description provided.