최근 검색


최근 검색 없음

CORS error after successfully creating ticket



2022년 9월 09일에 게시됨

I'm having an issue with returning a response after creating a ticket. Note, the ticket gets created in Zendesk, so everything works except returning a response back to the browser. Here's my code:

const request = await fetch("https://{obscured}.zendesk.com/api/v2/tickets", {
    method: "POST",
    headers: {
        "Authorization": "Basic "+wp_helper.zendesk_token,
        "Content-Type": "application/json",
    },
    body: JSON.stringify({
        "ticket": {
            "comment": {
                "body": comment,
                "uploads": [
                    file_token
                ]
            },
            "requester": { "locale_id": 1, "name": full_name, "email": email },
            "subject": subject
        }
    })
});
let response = await request.json();
console.log(response);

These are the errors I'm getting in the browser console after the ticket is successfully created:

Tag: Eric Nelson


0

1

댓글 1개

image avatar

Eric Nelson

Zendesk Developer Advocacy

Hey Luke,

This is expected behavior, I'd suggest reading our article on working with cross origin requests here.

Thanks

0


댓글을 남기려면 로그인하세요.

원하는 정보를 못 찾으셨나요?

새 게시물