I am making an attempt to do a brilliant easy fetch to seize some consumer information for my WP web site. This URL works 100% in Postman and I get every part I want. Nevertheless, within the browser and script, the response is ALWAYS an empty array.
This is my script:
fetch(url, {
methodology: "GET",
headers: {
"authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjIsIm5hbWUiOiJsemFrb29yIiwiaWF0IjoxNjYzMTA5MzU2LCJleHAiOjE4MjA3ODkzNTZ9.2l957IqslJBsvY9MrV5dT0ykod7kloFCc5qSxGeGlT0",
"cache-control": "no-cache",
'Content material-Sort': 'software/json;charset=UTF-8'
}
})
// Deal with success
.then(response => response.json()) // convert to json
.then(json => console.log(json)) //print information to console
.catch(err => console.log('Request Failed', err)); // Catch errors
I am unsure what I am doing flawed. I’ve tried virtually every part I can consider. Postman provides me the right JSON response each time.
The URL is that this: /wp-json/wp/v2/customers/
Uncooked:
{"id":668,"title":"008LT","url":"","description":"","hyperlink":"creator/008lt/","slug":"008lt","avatar_urls":{"24":"wp-content/plugins/buddyboss-platform/bp-core/pictures/profile-avatar-buddyboss-50.png","48":"wp-content/plugins/buddyboss-platform/bp-core/pictures/profile-avatar-buddyboss-50.png","96":"wp-content/plugins/buddyboss-platform/bp-core/pictures/profile-avatar-buddyboss-50.png"},"meta":{"project_code":[null],"hours_approved":[],"hours_used":[]},"acf":{"password_was_reset":"sure","acad_coordinator":"Mariah G.","project_poc":"Another person","student_admin":"Take a look at 1","admin_contact":"Somebody","project_id":"11104.0028.001","hd_project_id_status":"","primary_language":"lithuanian (lit)","secondary_language":"russian (rus)","approved_hours":30,"used_hours":15,"todays_appointments":"","scheduled_instructor":"","training_focus":"","jlu":"","let_status":"","cl150_status":"","iltp":"","pmo_account-type":"","hd_account_status":"","tutor_orientation":"","class_activity":"","next_test":"","test_date":"","class_recording":"","last_updated":null,"student_category":"dlt","student-iltp":""},"_links":{"self":[{"href":"wp-json/wp/v2/users/668"}],"assortment":[{"href":"wp-json/wp/v2/users"}],"programs":[{"embeddable":true,"href":"wp-json/ldlms/v2/users/668/courses"}],"teams":[{"embeddable":true,"href":"wp-json/ldlms/v2/users/668/groups"}],"course-progress":[{"embeddable":true,"href":"wp-json/ldlms/v2/users/668/course-progress"}],"quiz_progress":[{"embeddable":true,"href":"wp-json/ldlms/v2/users/668/quiz-progress"},{"embeddable":true,"href":"wp-json/ldlms/v2/groups/668/quiz-progress"},{"embeddable":true,"href":"wp-json/ldlms/v2/groups/668/quiz-progress"}]}}