figma-plugin icon indicating copy to clipboard operation
figma-plugin copied to clipboard

[URL sync] Support sending a POST request

Open dutscher opened this issue 3 years ago • 4 comments

Hi there and thanks for all ya hard work,

we want to use your URL Provider plugin which is atm READONLY. https://github.com/six7/figma-tokens/blob/a806b12a3b5ada8c4da33e5c5db6eb17f122702b/src/app/store/providers/url.tsx

We figure out that this works with our in house VPN like a charm and therefore no github or jsonbin is necessary. Because we cant use cloud services.

Is It possible to add and export POST request to another URL? So we can build our own in house json storage?

Cheers and thanks in advance.

dutscher avatar Nov 10 '21 15:11 dutscher

I would say this should be possible! I'm not sure what would be required, but I guess it would be split up into GET URL and POST URL. GET is required, POST is optional.

Is there anything else that you think would be required to make this work? Additional headers only on POST, or can these reuse what GET is using?

six7 avatar Nov 10 '21 19:11 six7

It should be simple as this code sample:

await fetch(postUrl, {
    method: 'post',
    headers: {
        'Content-type': 'application/json'
    },
    body: JSON.stringify({
        tokens
    }),
});

yes a split up in GET and POST is useful. GET and POST can have be different URL's but due the different METHOD it could be the same. is the URL stored in LocalStorage?

cheers and thanks for the fast reply.

dutscher avatar Nov 11 '21 09:11 dutscher

It would be great to also have an ability to edit headers. The use case is to trigger remote API to process payload. My current use case would be to trigger GitHub action. I don't want to create PR directly in plugin but to do some processing beforehand and automate PR naming, and it's description.

oleksify avatar Nov 13 '21 10:11 oleksify

I'd love to see this so we can create our own integration to secure our repo credentials

superbia avatar Sep 01 '22 05:09 superbia

Closing this as we technically have support for this via Generic Versioned Storage which is like a better URL sync. https://docs.tokens.studio/sync/generic-storage

six7 avatar Feb 14 '23 18:02 six7