Help

Keep getting weird error

Topic Labels: Scripting extentions
1441 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Kosta_Kondraten
7 - App Architect
7 - App Architect

I keep getting error:
SyntaxError: Unexpected end of JSON input
at main on line 32

Is this something to do with my return JSON string from my endpoint or something to do with my code? Here is the code

let WPtable = base.getTable("New WP");
// Prompt the user to pick a record 
// If this script is run from a button field, this will use the button's record instead.
let record = await input.recordAsync('Select a record to use', WPtable);

let blogTitle = record.getCellValue("Title");
let wpContent = record.getCellValue("Content");
let c_name = record.getCellValue("Name"); // had to change to c_name because Visual Studio code was saying name is deprecated just in case I'm using a namespace
let bannerhead = record.getCellValue("Bannerhead");
let headline = record.getCellValue("Headline");
let subheadline = record.getCellValue("Subheadline");
let cta_text = record.getCellValue("CTA Text");
let cta_link = record.getCellValue("CTA Link");
let short_path = record.getCellValue("Short Path"); // this is what's at the end of the shortlink created e.g bit.ly/short-path-is-here


const data = { title: blogTitle, name: c_name, function: 1, excerpt: 'The short version', content: wpContent, bannerhead: bannerhead, headline: headline, subheadline: subheadline, cta_text: cta_text, cta_link: cta_link, short_path: short_path };


console.log(JSON.stringify(data));

let response = await remoteFetchAsync('http://147.182.192.192/the_vision.php', {
    method: 'POST',
    body: JSON.stringify(data),
    headers: {
        'Content-Type': 'application/json',
        'Authorization' : 'Basic d2h5d29udHlvdWNvbm5lY3Q6Y2N1WSAxWWhkIDdsTmkgMzdWSSB5MVlyIDYySEs='
    },
});

console.log(response);
let body = await response.json();
console.log(body);
//console.log(body.ashram);
//console.log(body.server);
//console.log("And the URL is...");
//console.log(body.url);

WPtable.updateRecordAsync(record, {
    "Permalink": body.url,
    "Shortlink": body.shortlink
})     
1 Reply 1
Kosta_Kondraten
7 - App Architect
7 - App Architect

P.S. Return from that URL is JSON below:

{“url”:“https://staging2.conveyancingqld.com/for-you/justine-queen-announcement/”,“shortlink”:“https://showme.headstudios.com.au/cute-world”}

so not sure why it isn’t being read really confused