需要帮助解释 Airtable 脚本块语法错误

时间:2021-07-21 16:10:54

标签: airtable

我在 Airtable 中添加了一个相当简单的脚本块,它通过我的应用程序上的端点发布更新。运行时的错误如下,但无法弄清楚这是指什么。

觉得这可能很简单,有人有什么想法吗?

ERROR
SyntaxError: Unexpected token C in JSON at position 0

at Unexpected token C in JSON at position 0
let token = await input.textAsync("Insert Token")
let table = base.getTable("test");
let record = await input.recordAsync('Pick a record',table)
let initialRaw = record.getCellValue("updatedcontent")
let recordid = "60cf7b6133fed78cdae3ca48"

let env = await input.buttonsAsync('Choose Environment', 
['Test', 
'Live'])
var exampleRequest = {
    "items":[
        {"ID":"1234",
        "name":"Mr Smith"}
    ]
};
        
var exampleRaw = JSON.stringify(exampleRequest)
let raw = JSON.stringify(initialRaw)
let url=''
if (env=='live')
    {
        url= 'https://live.com/user/'+recordid
    }
else
    {
        url='https://test.com/user/'+recordid
    }

console.log(url)
console.log(initialRaw)
console.log(raw)
console.log(exampleRequest)
console.log(exampleRaw)

//POST API LOCATION call
    var myHeaders = new Headers();
    myHeaders.append("Authorization", "Bearer "+token);
    myHeaders.append("Content-Type", "application/json")
    myHeaders.append("Accept", "application/json")
    
    var requestPostOptions = {
        method: 'POST',
        headers: myHeaders,
        redirect: 'follow',
        body: exampleRaw
        };
    console.log(requestPostOptions)
    let orderResponse = await fetch(url, requestPostOptions);
    let finalResponse = await orderResponse.json()
    console.log(finalResponse)

0 个答案:

没有答案