A
A
Artemiy_P2020-11-22 21:57:14
JavaScript
Artemiy_P, 2020-11-22 21:57:14

How to write a POST request with JSON and authorization in JavaScript?

Good afternoon!

Tell me how to write a POST request in JavaScript?
Initial data:5fbab450ca163612887171.png5fbab43ee991f626758849.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-11-22
@Artemiy_P

For example like this

fetch(YOUR_URL, {
    method: 'POST',
    headers: {
        'Client-Id': YOUR_CLIENT_ID,
        'Api-Key': YOUR_API_KEY,
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        offer_id: YOUR_OFFER_ID,
        product_id: YOUR_PRODUCT_ID,
        sku: YOUR_SKU
    })
}).then(response => response.json()).then(data => {
    console.log(data);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question