Help

API redirection : false

Topic Labels: API
1997 4
cancel
Showing results for 
Search instead for 
Did you mean: 
Marc_Justin_Rai
6 - Interface Innovator
6 - Interface Innovator

Hello, i tried the resp.json, resp, resp.text but the result of my api request hasn’t shown, sometimes it show the redirection:false when i use the resp.json and resp.text it show only “function”

const ws = "https://api.writesonic.com/v1/business/content/ai-article-writer-v2?&end_user_id=test1&engine=economy&language=en";
let config = {
  method: 'post',
  headers: { 
    'Content-Type': 'application/json', 
    'Accept': 'application/json', 
    'X-API-KEY': 'apikey'
  },
  body : JSON.stringify({
            "article_title": atitle,
            "article_intro": asection,
            "article_sections": [
              'Tourist information about the city of Vitrolles in the department of Bouches-du-Rhone 13',
              'Tourist information about the city of Abbeville in the department of Somme 80',
              'Tourist information about the city of Ablon-sur-Seine in the department of Val-de-Marne 94'
            ]
          }), 
        data : data
};
    try {
      const resp = await remoteFetchAsync(ws, config);
      console.log(resp.json);
    }
    catch(error) {
       console.log('Error happened here!')
       console.error(error)
    }
4 Replies 4

Try something like

const data = resp.json()
console.log(data)

Hello, Thank you for the reply but i tried this one, it shown only the redirection : false error

No, Anyway Thank you for you replies i tried last night a different approach using await and call for a library that i’m missing. It works well now.

await getAxios()
async function getAxios() {
  const response = await fetch("https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js");
  const minifiedLibrary= await response.text();
  eval(minifiedLibrary)
}
const ws = "https://api.writesonic.com/v1/business/content/ai-article-writer-v2?&end_user_id=test1&engine=economy&language=en";
// import axios from "axios";
let config = {
  method: 'post',
  url : "https://api.writesonic.com/v1/business/content/ai-article-writer-v2?&end_user_id=test1&engine=economy&language=en",
  headers: { 
    'Content-Type': 'application/json', 
    'Accept': 'application/json', 
    'X-API-KEY': 'apikey'
  },
  data : data
};
await axios(config).then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});