Plugin Directory

Changeset 3208480


Ignore:
Timestamp:
12/16/2024 10:40:46 AM (15 months ago)
Author:
sobolddev
Message:

Fix: Updated makeFrontSummaryRequest to use query parameters for GET request

Location:
ai-summarizer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ai-summarizer/tags/1.0.1/includes/assets/ai-summarizer.js

    r3205622 r3208480  
    288288     * @returns {Object} - The summary response or an error
    289289     */
     290    // async function makeFrontSummaryRequest(data) {
     291    //     try {
     292    //         const response = await fetch(aiSummarizer.rest_url_get_summary, {
     293    //             method: "GET",
     294    //             headers: {
     295    //                 "Content-Type": "application/json",
     296    //                 "X-WP-Nonce": aiSummarizer.nonce,
     297    //             },
     298    //             body: JSON.stringify(data),
     299    //         });
     300    //         return await response.json();
     301    //     } catch (error) {
     302    //         console.error("Front summary request failed:", error);
     303    //         return { success: false, error };
     304    //     }
     305    // }
    290306    async function makeFrontSummaryRequest(data) {
    291307        try {
    292             const response = await fetch(aiSummarizer.rest_url_get_summary, {
     308            // Convert data object to query parameters
     309            const queryParams = new URLSearchParams(data).toString();
     310            const urlWithParams = `${aiSummarizer.rest_url_get_summary}?${queryParams}`;
     311
     312            const response = await fetch(urlWithParams, {
    293313                method: "GET",
    294314                headers: {
     
    296316                    "X-WP-Nonce": aiSummarizer.nonce,
    297317                },
    298                 body: JSON.stringify(data),
    299318            });
     319
    300320            return await response.json();
    301321        } catch (error) {
  • ai-summarizer/trunk/includes/assets/ai-summarizer.js

    r3205622 r3208480  
    288288     * @returns {Object} - The summary response or an error
    289289     */
     290    // async function makeFrontSummaryRequest(data) {
     291    //     try {
     292    //         const response = await fetch(aiSummarizer.rest_url_get_summary, {
     293    //             method: "GET",
     294    //             headers: {
     295    //                 "Content-Type": "application/json",
     296    //                 "X-WP-Nonce": aiSummarizer.nonce,
     297    //             },
     298    //             body: JSON.stringify(data),
     299    //         });
     300    //         return await response.json();
     301    //     } catch (error) {
     302    //         console.error("Front summary request failed:", error);
     303    //         return { success: false, error };
     304    //     }
     305    // }
    290306    async function makeFrontSummaryRequest(data) {
    291307        try {
    292             const response = await fetch(aiSummarizer.rest_url_get_summary, {
     308            // Convert data object to query parameters
     309            const queryParams = new URLSearchParams(data).toString();
     310            const urlWithParams = `${aiSummarizer.rest_url_get_summary}?${queryParams}`;
     311
     312            const response = await fetch(urlWithParams, {
    293313                method: "GET",
    294314                headers: {
     
    296316                    "X-WP-Nonce": aiSummarizer.nonce,
    297317                },
    298                 body: JSON.stringify(data),
    299318            });
     319
    300320            return await response.json();
    301321        } catch (error) {
Note: See TracChangeset for help on using the changeset viewer.