Edukira joan

MediaWiki eztabaida:Gadget-cards.js

Orriaren edukia ez da onartzen beste hizkuntza batzuetan.
Wikipedia, Entziklopedia askea

Error handling[aldatu iturburu kodea]

Hey @User:Theklan here's some error handling - hopefully you can adapt as you wish?:

const ErrorWidget = {
    components: {
        CdxMessage
    },
	props: {
		message: String
	},
    template: `<cdx-message type="error">
	    <p><strong>Currently unable to load cards. The error is provided below.</strong></p>	<p>{{ message }}</p></cdx-message>
</div>`
};

 function loadPageViews( target, url, exclude, limit ) {
    $.get( url )
        .then((data) => {
            titleExpand(
                data.items[0].articles.map((a) => ( {
                    title: a.article
                }) )
                .filter((a) => !a.title.includes(':') && !exclude.includes(a.title))
                .slice(0, limit)
            ).then( ( titles ) => {
                Vue.createApp( CardWidget, {
                    titles
                } ).mount( target )
            })
        }, ( error ) => {
            let message;
            try {
                const r = JSON.parse( error.responseText );
                message = r.detail;
            } catch ( e ) {
                message = 'Unknown';
            }
            Vue.createApp( ErrorWidget, {
                message
            } ).mount( target );
        }  );
}

Jdlrobson (eztabaida) 06:33, 21 maiatza 2024 (CEST)[Erantzun]

Hello! I have added the code and translated. I don't unsertand if I have to change the "message = 'Unknown'" section to show a different message there. Also, what template does it load with {{ message }}? Theklan (eztabaida) 17:22, 21 maiatza 2024 (CEST)[Erantzun]