Feb 04, 2022 12:00 AM
Hello, i got this error but i don’t have any idea where to look for to fix this issue
1. Error {name: "SyntaxError"}
1. name: "SyntaxError"
Here is the code :
const wordAI = await remoteFetchAsync("https://github.com/braytonstafford/wordai",
{
method : "POST",
header : {
'Content-type' : "application/json"
},
email: email,
key: wakey,
input : "This is a test",
rewrite_num: 2,
uniqueness : 3,
output: 'json',
quality: 'Regular',
});
try {
const data = await wordAI.json()
console.log('response data?', data)
} catch(error) {
console.log('Error happened here!')
console.error(error)
}
Feb 04, 2022 10:16 AM
I’ll bet this is not the endpoint for the API.
Feb 06, 2022 11:20 PM
Yes sorry i fetch the correct github api link. Here it is:
But i get this error after.
Error: Response status was 301 ‘Moved Permanently’ but redirect mode was set to ‘error’
Here is my new code, I checked first if i can connect the github properly
let url2 = "https://github.com/braytonstafford/wordai.git";
const headers2 = {
'Content-Type': 'application/json',
'method' : 'GET'
}
const wordAI = await remoteFetchAsync(url2, headers2);
try {
const data = await wordAI.json()
console.log('response data?', data)
} catch(error) {
console.log('Error happened here!')
console.error(error)
}
Feb 07, 2022 04:42 AM
GitHub pages are not API endpoints. You need to sign up for an account at WordAI, login, locate the documentation that tells you what API endpoint to use for requests.
Feb 07, 2022 06:42 PM
Yes, but the WordAPI documentation only has the example for curl fetch, i don’t know any alternative code that is related to JSON for curl. i only found this github.
Feb 08, 2022 07:39 AM
I assume you have an account and you are paying $57/month for the service.
Go to this URL and look for the getting started section and note the API endpoint. That’s the only way to utilize this API. Sending WordAPI requests to GitHub will not magically provide free access to their paid service.
Feb 08, 2022 06:31 PM
Yes, I’ve taken a look on the wordai documentation on API. As i don’t have clue how to manage the API endpoint requests on JSON as they provided an example of using curl method only.
Feb 09, 2022 01:00 AM
@Bill.French May i add a new question here, Is there a way to convert the record to utf-8?
As my records contains some of this text “Alès”
Feb 09, 2022 06:30 AM
Please publish that example so we can see it.
Feb 09, 2022 06:34 AM
Yes. Include Content-type: application/json; charset=utf-8
in the message header.
Feb 09, 2022 06:13 PM
Hello, I’m new in airtable, may i have an example how to add the header in the header? I only know how to do this one whenever i have to use the await fetch or remotefetchasync.
Feb 09, 2022 06:15 PM
Hi, This is the example they provide.
curl -d "email="+email+"&key="+wakey+"&input=This is a test.&rewrite_num=2&uniqueness=3&return_rewrites=true" -X POST http://localhost:4050/api/rewrite
Feb 09, 2022 07:24 PM
Hello, i tried and test the Content-type:application/json;charset=utf-8
I only tested this kind of method as i don’t know how to add the message header if i’m going to use the table.selectRecordAsync
as my primary.
It still shows the “Alès”.
Thank you for the assistance.
const url = "https://api.airtable.com/v0/appV1begTvublATlv/tblR5JePA9pLYP1YQ?api_key="+MY_API_KEY; //population
const headers = {
"Content-type": 'application/json;charset=utf-8',
'method' : 'GET'
}
Feb 10, 2022 05:21 AM
This suggests their example assumes the web service has been downloaded and is running on your own computer. have you done that?
Feb 10, 2022 05:25 AM
Unfortunately, this has nothing to do with Airtable. The questions you are asking are wholly about integration architectures that separate and apart from making Airtable solutions. This is the realm of integration and it requires some degree of experience with APIs and HTTP(s); code that you can get wrong about a hundred different ways and code that you can get right only a few ways.
I suggest you find a consultant in the community who is willing to work with you to solve this challenge.
Feb 10, 2022 05:33 AM
But, isn’t that the accurate data in the table? If not this, what would you expect?
Feb 10, 2022 09:05 AM
I’m expecting to remove the accent character and the output will be Ales.
Feb 10, 2022 09:23 AM
That’s not what UTF-8 encoding is designed to do. It’s the opposite; it sustains the proper exchange of values between unlike OSes and other systems.
You need diacritics transformation using RegEx -
const str = "Crème Brulée"
str.normalize("NFD").replace(/[\u0300-\u036f]/g, "")
> "Creme Brulee"
Feb 10, 2022 09:51 AM
Thank you, i have to insert all the accent letters inside the regex then.
Feb 13, 2022 07:55 PM
I haven’t tried this as i’m doing the test on airtable script.