0

I'm trying to access the API of Codeship in js but it gives the code in cURL

This is it in curl:

curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" --user '<your email>:<your password>' https://api.codeship.com/v2/auth

I'm not sure how to pass in the arguments or user

This is the api docs if you needed it https://apidocs.codeship.com/v2

Thanks for any help on this.

3
  • 2
    just replace <your email>:<your password> Commented Jul 28, 2020 at 6:47
  • Is your question how about to do this in node.js ? Commented Jul 28, 2020 at 6:48
  • Does this answer your question? What does '--user' mean with curl Commented Jul 28, 2020 at 6:52

1 Answer 1

1

If you're asking how to do this in node.js, here's an example using the commonly used axios http-request library:

const axios = require('axios');

async function sendRequest() {

    const requestConfig = {
        method: 'post',
        url: 'https://api.codeship.com/v2/auth',
        headers: {
            'Content-Type': 'application/json'
        },
        auth: {
            username: 'your-user',
            password: 'your-password'
        }
    };

    try {
        const response = await axios(requestConfig);
        console.log(JSON.stringify(response.data));
        return response;    
    } catch (error) {
        console.log(error);
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.