Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nombed not return all elements #1481

Open
JonathanJvs opened this issue Aug 14, 2024 · 1 comment
Open

nombed not return all elements #1481

JonathanJvs opened this issue Aug 14, 2024 · 1 comment

Comments

@JonathanJvs
Copy link

When we get an request with the proxy, the returned just the url in data, not the html and others elements in the preview of response.

Proposition:

`function (data) {
// Build request URL
var requestUrl = new URL(trumbowyg.o.plugins.noembed.proxy);
Object.keys(data).forEach((key) => {
requestUrl.searchParams.append(key, data[key].trim());
});

                                // Launch async request
                                fetch(requestUrl, {
                                    method: 'GET',
                                    cache: 'no-cache',
                                    signal: AbortSignal.timeout(2000)
                                }).then((response) => {
                                    return response.json().then((json) => {
                                        if (trumbowyg.o.plugins.noembed.success) {
                                            trumbowyg.o.plugins.noembed.success(json, trumbowyg, $modal);
                                            return;
                                        }

                                        if (!json.html) {
                                            trumbowyg.addErrorOnModalField(
                                                $('input[type=text]', $modal),
                                                json.error
                                            );
                                            return;
                                        }

                                        trumbowyg.execCmd('insertHTML', json.html);
                                        setTimeout(function () {
                                            trumbowyg.closeModal();
                                        }, 250);
                                    });
                                }).catch((...args) => {
                                    if (trumbowyg.o.plugins.noembed.error) {
                                        trumbowyg.o.plugins.noembed.error(...args);
                                        return;
                                    }

                                    trumbowyg.addErrorOnModalField(
                                        $('input[type=text]', $modal),
                                        trumbowyg.lang.noembedError
                                    );
                                });
                            }`
@bastienJanon
Copy link

bastienJanon commented Sep 6, 2024

I reproduce, i tested my proxy which return truly html but I don't know why sucess callback return only a json like {video: "url-of-video"}

EDIT: i just found the problem
the case only append when a plugins.noembed.sucessCallback is provided,

image L.122 you send data (data request) instead of response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants